I cannot seem to import beautifulsoup or requests however everything seems to be in order from what I have read online. I'm not sure what I have missed.
PATH:
C:\Users\ross\AppData\Local\Programs\Python\Python37
C:\Users\ross\AppData\Local\Programs\Python\Python37\Scripts
Script:
import requests
from bs4 import BeautifulSoup
pip3 install output:
Requirement already satisfied: bs4 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (0.0.1)
Requirement already satisfied: requests in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (2.22.0)
Requirement already satisfied: beautifulsoup4 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (from bs4) (4.8.0)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (2019.6.16)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (1.25.3)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: soupsieve>=1.2 in c:\users\ross\appdata\local\programs\python\python37-32\lib\site-packages (from beautifulsoup4->bs4) (1.9.2)
python --version output:
Python 3.7.4
python -m pip freeze output:
astroid==2.1.0
beautifulsoup4==4.8.0
bs4==0.0.1
certifi==2019.6.16
chardet==3.0.4
colorama==0.4.1
idna==2.8
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
pylint==2.2.2
requests==2.22.0
six==1.12.0
soupsieve==1.9.2
urllib3==1.25.3
wrapt==1.11.0
import sys; print(sys.path) output:
['C:\\Users\\ross.watson\\Downloads', 'C:\\Users\\ross.watson\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\ross.watson\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\ross.watson\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\ross.watson\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\ross.watson\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Users\\ross.watson\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
pip --version output:
pip 19.2.1 from c:\users\ross.watson\appdata\local\programs\python\python37-32\lib\site-packages\pip (python 3.7)
Final Edit
I'm an idiot, I remove the 3.7.2 64 bit version and it worked fine. The issue was having multiple versions. Not sure why the install would install 2 different version for 32/64 bit. Thank all for you help.
Related
I'm using mysql with flask for developing a basic website and I'm getting ModuleNotFound error even if I have the module installed. Can someone solve this ?
File "c:/Users/prshi/Desktop/Py files/FLASK app/app.py", line 3, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
PS C:\Users\prshi\Desktop\Py files\FLASK app> pip install flask-mysqldb
Requirement already satisfied: flask-mysqldb in c:\python39\lib\site-packages (0.2.0)
Requirement already satisfied: Flask>=0.10 in c:\python39\lib\site-packages (from flask-mysqldb) (1.1.2)
Requirement already satisfied: mysqlclient in c:\python39\lib\site-packages (from flask-mysqldb) (1.4.6)
Requirement already satisfied: Werkzeug>=0.15 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.0.1)
Requirement already satisfied: Jinja2>=2.10.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (2.11.2)
Requirement already satisfied: itsdangerous>=0.24 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.1.0)
Requirement already satisfied: click>=5.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (7.1.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\python39\lib\site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb) (1.1.1)
PS C:\Users\prshi\Desktop\Py files\FLASK app>
This a common python path issue, to make sure it isn't your case, type :
import sys
print(sys.path)
and check if it contains:
/usr/local/lib64/python3.6/site-packages
The problem is that you install the package using pip somewhere, and you're trying to import it from somewhere else where it's not installed. The trick to solve it is by running this command :
export PYTHONPATH=$PYTHONPATH:/path/to/your/modules
I want to use requests module on python3.7
But when in run
import requests
it throws error like this
ModuleNotFoundError: No module named 'requests'
However, it works fine with python3.5
When I run pip and pip3 install requests it says
root#helloasc:~# pip install requests
Requirement already satisfied: requests in /usr/local/lib/python3.5/dist-packages (2.23.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.5/dist-packages (from requests) (1.25.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.5/dist-packages (from requests) (2020.4.5.1)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.5/dist-packages (from requests) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.5/dist-packages (from requests) (2.9)
I'm still trying to master the science of installing packages via pip. When I run pip to install geocoder, I get the following:
(base) C:\Users\MBSanders>python -m pip install geocoder
Requirement already satisfied: geocoder in c:\programdata\anaconda3\lib\site-packages (1.38.1)
Requirement already satisfied: requests in c:\programdata\anaconda3\lib\site-packages (from geocoder) (2.21.0)
Requirement already satisfied: future in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.17.1)
Requirement already satisfied: click in c:\programdata\anaconda3\lib\site-packages (from geocoder) (7.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from geocoder) (1.12.0)
Requirement already satisfied: ratelim in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.1.6)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2019.3.9)
Requirement already satisfied: idna<2.9,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (3.0.4)
Requirement already satisfied: decorator in c:\programdata\anaconda3\lib\site-packages (from ratelim->geocoder) (4.4.0)
When I run
os.getcwd()
in spyder/python, I get
'C:\\Users\\MBSanders'
My question is, why do I get
ModuleNotFoundError: No module named 'geocoder'
When I run
import geocoder
I'm somewhat new to python. Please let me know if additional info is needed to trouble shoot. I'm within a federal agency so I do not have admin rights.
When I run sys.path in the console, I get
sys.path
Out[12]:
['F:\\Users\\MBSanders',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\python37.zip',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3',
'',
'C:\\Users\\MBSanders\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\IPython\\extensions',
'F:\\Users\\MBSanders\\.ipython']
Assuming you're running python on the terminal, and python is the command you're using to run it, try doing python -m pip install geocoder. That'll install it for the python build you want to use. Or if you know the full path to the python build you're using, you can do something similar like /path/to/python -m pip install geocoder.
if you are using python 3.7 or 3.8 you may need to pip3.7 or pip3.8 install if you OS is recognizing a 2.x version as default
I'm trying to install boto3 on my mac (high sierra 10.13.3) and tried to follow : https://github.com/boto/boto3. I had already installed python 3 using homebrew before, but when I tried to see pip --version, I get error.
So, I did
1) modify .bash_profile to add
alias pip=pip3
2) verify
$ pip --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
3)
$ pip install boto3
Collecting boto3
Downloading boto3-1.5.36-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 474kB/s
Collecting botocore<1.9.0,>=1.8.50 (from boto3)
Downloading botocore-1.8.50-py2.py3-none-any.whl (4.1MB)
100% |████████████████████████████████| 4.1MB 376kB/s
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: docutils>=0.10 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in ./Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
Installing collected packages: botocore, boto3
Found existing installation: botocore 1.8.20
Uninstalling botocore-1.8.20:
Successfully uninstalled botocore-1.8.20
Successfully installed boto3-1.5.36 botocore-1.8.50
4) just to make sure this was fine, I ran
$ pip3 install boto3
Requirement already satisfied: boto3 in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: botocore<1.9.0,>=1.8.50 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: docutils>=0.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
5) but, now when I ran import boto3 in Idle, I get error
import boto3
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
I even tried to change path in .bash_profile, but it did not work.
Thoughts?
It worked for me to just copy all of packages with "bolo" in the name from the Python 3.7 folder to the Python 2.7 folder:
/usr/local/lib/python3.7/site-packages $ sudo cp -R boto* /Library/Python/2.7/site-packages/.
Hello I am trying to send an API request to http via Python's requests package and getting an ImportError while using import requests for python 3.5.2.
I tried to install requests package via pip3.5 install requests that says
Requirement already satisfied: requests in /usr/lib/python3.5/site-packages
Requirement already satisfied: idna<2.6,>=2.5 in /usr/lib/python3.5/site-packages (from requests)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/lib/python3.5/site-packages (from requests)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.5/site-packages (from requests)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.5/site-packages (from requests)
if I list the install packages pip3.5 list I got
appdirs (1.4.3)
bencode (1.0)
better-bencode (0.2.1)
certifi (2017.7.27.1)
chardet (3.0.4)
click (6.7)
Flask (0.12.2)
gevent (1.2.2)
greenlet (0.4.12)
humanfriendly (4.4)
idna (2.5)
itsdangerous (0.24)
Jinja2 (2.9.6)
magneticod (0.6.0)
magneticow (0.6.0)
MarkupSafe (1.0)
Naked (0.1.31)
parse-torrent-name (1.1.1)
pip (9.0.1)
PyYAML (3.12)
requests (2.18.3) <--- Here its already installed
setuptools (33.1.1)
urllib3 (1.22)
uvloop (0.8.0)
Werkzeug (0.12.2)
this is how I am running the python script python3 script.py (interpreting with python3.5)
your help would be appreciated. Thank you!