Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bs4.FeatureNotFound:。。。带有MacOS和Conda/Python 3的lxml_Python_Python 3.x_Beautifulsoup_Lxml - Fatal编程技术网

bs4.FeatureNotFound:。。。带有MacOS和Conda/Python 3的lxml

bs4.FeatureNotFound:。。。带有MacOS和Conda/Python 3的lxml,python,python-3.x,beautifulsoup,lxml,Python,Python 3.x,Beautifulsoup,Lxml,我得到的错误与这个4年前的线程中的错误相同: 但是我使用MacOS、IntelliJ和Conda/Python 3作为我的环境。我尝试过的事情: $ STATIC_DEPS=true sudo pip install lxml 及 之后: $ python3 -m pip install lxml Requirement already satisfied: lxml in /anaconda3/lib/python3.6/site-packages (4.2.4) 但在IntelliJ中执

我得到的错误与这个4年前的线程中的错误相同:

但是我使用MacOS、IntelliJ和Conda/Python 3作为我的环境。我尝试过的事情:

$ STATIC_DEPS=true sudo pip install lxml

之后:

$ python3 -m pip install lxml
Requirement already satisfied: lxml in /anaconda3/lib/python3.6/site-packages (4.2.4)
但在IntelliJ中执行脚本时,我仍然会遇到相同的错误:

  File "/Users/blabla/katalog-scanner/KatalogScanner.py", line 149, in <module>
    soup = BeautifulSoup(html, 'lxml')
  File "/anaconda3/envs/katalog-scanner/lib/python3.6/site-packages/bs4/__init__.py", line 198, in __init__
    % ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
文件“/Users/blabla/katalog scanner/KatalogScanner.py”,第149行,在
soup=BeautifulSoup(html,“lxml”)
文件“/anaconda3/envs/katalog scanner/lib/python3.6/site packages/bs4/_init__.py”,第198行,在_init中__
%“,”。连接(功能))
bs4.FeatureNotFound:找不到具有您请求的功能的树生成器:lxml。您需要安装解析器库吗?

我还尝试在代码中切换到
html5lib
,导致了相同的错误,即
html5lib
已被请求,但未找到。我还可以尝试什么?

我的机器上安装了多个Python,由

  • 自制
  • 水蟒
  • 易于安装
包管理器。我完全删除了anaconda实例(直接在我的macintosh hd下),删除了easy_install和
brew卸载python——强制删除我在usr/local/bin中的所有python实例(2.7、3.6、3.7)

然后我只使用自制软件安装:
brew安装python3

然后,需要通过打开将python和pip命令链接到python3/pip3

~/.bash_profile
把这个放在那里并保存:

alias python='python3'
alias pip='pip3'
然后刷新终端(可能需要完全重新启动,甚至需要重新启动操作系统):

然后,
python--version
应该显示您应该能够执行的最新3.x版本:(第二个命令启动python解释器,第四个命令结束它)

现在,您必须转到IntelliJ>File>Project Structure并将Python 3.x SDK添加到Plattform Settings(SDK)中,然后将Project Settings>Project SDK设置到该SDK中


在此之前,我还有一个IntelliJ.iml文件,但没有它,项目似乎可以正常运行

我认为您需要使用Conda进行安装,请尝试类似于
Conda install lxml的方法
alias python='python3'
alias pip='pip3'
source ~/.bashrc
pip install beautifulsoup4
python
import bs4
exit()