无法导入美化组和请求

2024-05-08 20:22:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的是Python。我已经安装了Beautifulsoup和请求模块。它还显示在我安装的软件包列表中

但是,当我尝试从conda提示符运行python文件时,会出现错误“没有名为'bs4'的模块/”没有名为'requests'的模块

已安装的软件包:

(dash) C:\Programs without certification\Ragesh\View\WebScrape>conda list -n das
h
# packages in environment at C:\Users\u815279\AppData\Local\Continuum\anaconda3\
envs\dash:
#
# 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 certification\Ragesh\View\WebScrape>scrape.py
Traceback (most recent call last):
  File "C:\Programs without certification\Ragesh\View\WebScrape\scrape.py", line
 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

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

(dash) C:\Programs without certification\Ragesh\View\WebScrape>

我完全被阻止了,尝试了谷歌搜索,pip也安装了,但没有运气。非常感谢您在这个问题上提供的任何帮助


Tags: pyviewanacondarequestscondawithoutforgescrape
2条回答

在conda terminal中,使用选项-n安装模块,命名所需的环境

我创建了一个环境“branchenv”和另一个环境“python385”。对于每个od:

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

您是否有多个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?>

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

相关问题 更多 >