无法导入BeautifulSoup和请求



我正在使用anaconda。我已经安装了Beautifulsoup和请求模块。它也显示在我安装的软件包列表中。

但是,当我尝试从conda提示符运行我的python文件时,我会得到错误"No Module named'bs4'"/"No Module named'requests'">

已安装的软件包:

(dash) C:Programs without certificationRageshViewWebScrape>conda list -n das
h
# packages in environment at C:Usersu815279AppDataLocalContinuumanaconda3
envsdash:
#
# Name                    Version                   Build  Channel
asn1crypto                1.3.0                    py37_0    anaconda
beautifulsoup4            4.8.2                    py37_0    anaconda
blas                      1.0                         mkl
ca-certificates           2020.1.1                      0    anaconda
certifi                   2019.11.28               py37_0    anaconda
cffi                      1.14.0           py37h7a1dbc1_0    anaconda
chardet                   3.0.4                 py37_1003    anaconda
click                     7.0                        py_0    conda-forge
cryptography              2.8              py37h7a1dbc1_0    anaconda
dash                      1.7.0                      py_0    conda-forge
dash-core-components      1.6.0                      py_0    conda-forge
dash-html-components      1.0.2                      py_0    conda-forge
dash-renderer             1.2.2                      py_0    conda-forge
dash-table                4.5.1                      py_0    conda-forge
flask                     1.1.1                      py_1    conda-forge
flask-compress            1.4.0                      py_0    conda-forge
future                    0.16.0                     py_1    conda-forge
icc_rt                    2019.0.0             h0cc432a_1
idna                      2.8                      py37_0    anaconda
intel-openmp              2019.4                      245
itsdangerous              1.1.0                      py_0    conda-forge
jinja2                    2.10.3                     py_0    conda-forge
markupsafe                1.1.1            py37he774522_0
mkl                       2019.4                      245
mkl-service               2.3.0            py37hb782905_0
mkl_fft                   1.0.15           py37h14836fe_0
mkl_random                1.1.0            py37h675688f_0
numpy                     1.17.3           py37h4ceb530_0
numpy-base                1.17.3           py37hc3f5095_0
openssl                   1.1.1                he774522_0    anaconda
pandas                    0.25.3           py37ha925a31_0
pip                       19.3.1                   py37_0
plotly                    4.4.1                      py_0
pycparser                 2.19                     py37_0    anaconda
pyopenssl                 19.1.0                   py37_0    anaconda
pysocks                   1.7.1                    py37_0    anaconda
python                    3.7.6                h60c2a47_2
python-dateutil           2.8.1                      py_0
pytz                      2019.3                     py_0
pyyaml                    5.2              py37he774522_0
requests                  2.22.0                   py37_1
retrying                  1.3.3                    py37_2
setuptools                44.0.0                   py37_0
six                       1.13.0                   py37_0
soupsieve                 1.9.5                    py37_0
sqlite                    3.30.1               he774522_0
urllib3                   1.25.8                   py37_0    anaconda
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_1
werkzeug                  0.16.0                     py_0    conda-forge
wheel                     0.33.6                   py37_0
win_inet_pton             1.1.0                    py37_0    anaconda
wincertstore              0.2                      py37_0
xlrd                      1.2.0                    py37_0
yaml                      0.1.7                    vc14_0    conda-forge

错误:

(dash) C:Programs without certificationRageshViewWebScrape>scrape.py
Traceback (most recent call last):
File "C:Programs without certificationRageshViewWebScrapescrape.py", line
1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
(dash) C:Programs without certificationRageshViewWebScrape>scrape.py
Traceback (most recent call last):
File "C:Programs without certificationRageshViewWebScrapescrape.py", line
1, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
(dash) C:Programs without certificationRageshViewWebScrape>

我完全被屏蔽了,试过谷歌,也安装过pip,但没有运气。非常感谢有关此问题的任何帮助

您有多个python安装吗?在您的终端、powershell等中尝试以下操作。

$ python
<Do you get a python prompt. If yes, then>
>>> import requests
<Is it able to import or does it show any error?>

如果以上不起作用,请尝试以下操作:

$ python3
<Do you get a python prompt. If yes, then>
>>> import requests
<Is it able to import or does it show any error?>

让我知道你在这方面有什么错误。如果没有,那么希望它是工作

在conda终端中,安装模块,用选项-n命名需要的环境。

我创造了一个环境";分支env";另一个被称为";蟒蛇385";。对于每个od:

conda install -c anaconda beautifulsoup4 -n python385
conda install -c anaconda beautifulsoup4 -n branch-env

最新更新