简体   繁体   中英

Unable to import BeautifulSoup and Requests

I am using anaconda. I have installed Beautifulsoup and requests module. It also shows up in my list of packages installed.

But when I try to run my python file from conda prompt , I get the error "No Module named 'bs4'" / "No module named 'requests'"

Installed packages:

(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

Error :

(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>

I am completely blocked due to this, tried googling , did pip install also but no luck. Any help regarding this issue is much appreciated

Do you have multiple python installation? Try the following in your terminal, powershell, etc.

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

if above doesn't work, try the following:

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

Let me know what errors you get in this. If not then hopefully it is working

In conda terminal, install your modules naming the enviroment where you need it with option -n.

I have created an enviroment "branch-env" and another called "python385". For each od these:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM