[英]ImportError: No module named 'bs4' with virtualenv python3
I know this is a common issue but I still can't figure how to make it work. 我知道这是一个普遍的问题,但是我仍然不知道如何使它起作用。 I'm trying to use bs4 inside a virtual environment but I have this error
ImportError: No module named 'bs4'
我正在尝试在虚拟环境中使用bs4,但出现此错误
ImportError: No module named 'bs4'
I have my virtualenv activated : 我激活了virtualenv:
pip install bs4
Requirement already satisfied: bs4 in /home/****/.virtualenvs/****/lib/python3.5/dist-packages
Requirement already satisfied: beautifulsoup4 in /home/****/.virtualenvs/****/lib/python3.5/dist-packages (from bs4)
My scripts start with 我的脚本开始于
!/usr/bin/python3.5
# -*-coding:Utf-8 -*
import json
import hashlib
from bs4 import BeautifulSoup
Any help is welcome ! 欢迎任何帮助!
Are you sure you are using the right python? 您确定使用的是正确的python吗? If you have everything tied up in a virtual environment, then you need to be using python from inside that virtualenv.
如果在虚拟环境中捆绑了所有内容,则需要在virtualenv内部使用python。 The command:
命令:
which python
at a bash prompt should tell you what the command: 在bash提示下应告诉您命令:
python
points to. 指着。 From the look of your script, you are asking it to go to /usr/bin/python3.5, which is not the directory of your virtualenv, by looking at your path, it is somewhere in your home directory.
从脚本的外观来看,您要求它转到/usr/bin/python3.5(这不是您的virtualenv的目录),通过查看路径,它位于主目录中。 Try changing the path in your script to the python virtualenv version (the one which pip has found bs4 in).
尝试将脚本中的路径更改为python virtualenv版本(pip在其中找到bs4的版本)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.