问题描述
我在Python工作和使用烧瓶中。当我在我的电脑上运行我的主要的Python文件,它完美的作品,但是当我启动venv和运行在终端的瓶Python的文件,它说,我的主要的Python文件中有无模块命名BS4。有任何意见或建议是大大AP preciated。
I'm working in Python and using Flask. When I run my main Python file on my computer, it works perfectly, but when I activate venv and run the Flask Python file in the terminal, it says that my main Python file has "No Module Named bs4." Any comments or advice is greatly appreciated.
推荐答案
激活的virtualenv,然后安装BeautifulSoup4:
Activate the virtualenv, and then install BeautifulSoup4:
$ pip install BeautifulSoup4
在安装 BS4
与的easy_install
,你安装了系统范围。所以,你的系统Python可以导入它,但不是你的virtualenv蟒蛇。
如果你不需要 BS4
被安装在系统Python路径中,卸载它,并把它放在你的virtualenv。
When you installed bs4
with easy_install
, you installed it system-wide. So your system python can import it, but not your virtualenv python.If you do not need bs4
to be installed in your system python path, uninstall it and keep it in your virtualenv.
有关virtualenvs的更多信息,请阅读本:http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
For more information about virtualenvs, read this: http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
这篇关于导入错误:没有模块命名BS4(BeautifulSoup)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!