1

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

imharindersingh
  • 166
  • 5
  • 14
Ragesh Kr
  • 1,573
  • 8
  • 29
  • 46

2 Answers2

0

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

imharindersingh
  • 166
  • 5
  • 14
  • Yes I assume I have multiple python installed. Is there any command which I can use to check that ? – Ragesh Kr Mar 03 '20 at 13:48
  • $ python >>> import requests { This part works } , but after activating my env , while running the python file I am getting 'No Module found Error" – Ragesh Kr Mar 03 '20 at 13:49
  • @RageshKr Are you suing virtualenv? According to https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/ , "virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip." So it means if you using virtual env then you need to install requests using pip in the same again. Try and let me know. – imharindersingh Mar 03 '20 at 18:19
  • I created a env using conda , and I have listed the installed packages – Ragesh Kr Mar 04 '20 at 05:07
  • "activate dash"(which is your env if i am right) -> "python --version". If this gives python 2.* then it is certain that you won't be able to use requests package as from question I can see requests is for python 3.7. Confirm if this is the case as this is just about troubleshooting installations in your development machine. – imharindersingh Mar 04 '20 at 08:14
  • Try running your program: (dash) C:\Programs without certification\Ragesh\View\WebScrape>python3 ./scrape.py – imharindersingh Mar 04 '20 at 08:23
0

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
CesareoAguirre
  • 1,557
  • 13
  • 11