I have installed obd library in python using : pip install obd. But when I tried to import eventlet this error occured:
pip install obd
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: obd in ./.local/lib/python3.6/site-packages (0.7.1)
Requirement already satisfied: pyserial==3.* in ./.local/lib/python3.6/site-packages (from obd) (3.4)
Requirement already satisfied: pint==0.7.* in ./.local/lib/python3.6/site-packages (from obd) (0.7.2)
pi#raspberrypi:~ $ python obd_hud_test.py
Traceback (most recent call last):
File "obd_hud_test.py", line 1, in <module>
import obd
ImportError: No module named obd
ow to rectify this error?
P.S : I am using Python 2.7
You can check which packages are installed with:
pip list
Hightlight specific package:
# Linux or other Unix-like systems
pip list | grep -i obd
# Windows
pip list | findstr /I obd
If it is not displayed, It is likely that something went wrong during the installation. You should reinstall.
OR
You should try to install a specific version
pip install "obd==0.7.1"
Related
import requests
from bs4 import BeautifulSoup
try:
source = requests.get('https://www.tripadvisor.com.sg/Hotels-g294265-Singapore-Hotels.html')
source.raise_for_status()
soup = BeautifulSoup(source.text, 'html.parser')
print(soup)
hotel = soup.find('div', class_="prw_rup prw_meta_hsx_responsive_listing ui_section listItem")
print(hotel)
except Exception as e:
print(e)
PS C:\Users\keeha\PycharmProjects\INF1002_Draft> py main1.py
Traceback (most recent call last):
File "C:\Users\keeha\PycharmProjects\INF1002_Draft\main1.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
PS C:\Users\keeha\PycharmProjects\INF1002_Draft> cd C:\Users\keeha\AppData\Local\Programs\Python\Python310\Scripts
PS C:\Users\keeha\AppData\Local\Programs\Python\Python310\Scripts> .\pip install requests
Requirement already satisfied: requests in c:\users\keeha\appdata\local\programs\python\python310\lib\site-packages (2.28.1)
Requirement already satisfied: idna<4,>=2.5 in c:\users\keeha\appdata\local\programs\python\python310\lib\site-packages (from requests) (3.4)
Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\keeha\appdata\local\programs\python\python310\lib\site-packages (from requests) (2.1.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\keeha\appdata\local\programs\python\python310\lib\site-packages (from requests) (2022.9.24)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\keeha\appdata\local\programs\python\python310\lib\site-packages (from requests) (1.26.12)
WARNING: You are using pip version 21.3.1; however, version 22.2.2 is available.
You should consider upgrading via the 'C:\Users\keeha\AppData\Local\Programs\Python\Python310\Scripts\python.exe -m pip install --upgrade pip' command.
PS C:\Users\keeha\AppData\Local\Programs\Python\Python310\Scripts> cd c:\users\keeha\appdata\local\programs\python\python310\lib\site-packages
PS C:\users\keeha\appdata\local\programs\python\python310\lib\site-packages> py C:\Users\keeha\PycharmProjects\INF1002_Draft\main1.py
Traceback (most recent call last):
File "C:\Users\keeha\PycharmProjects\INF1002_Draft\main1.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
PS C:\users\keeha\appdata\local\programs\python\python310\lib\site-packages>
I am trying to webscrape but it keep popping up the NoModuleFoundError while I have installed it in both my python and pycharm and I can find it in my settings. Please also a look at this link "i.pinimg.com/originals/e5/2e/6c/…" and see if you can notice anything that might cause the error?
To install requests module on Debian/Ubuntu for Python 2:
$ sudo apt-get install python-requests
And for Python 3 the command is:
$ sudo apt-get install python3-requests
Windows
Use
pip install requests
(or
pip3 install requests for python3)
if you have pip installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)
Alternatively from a cmd prompt, use > Path\easy_install.exe requests, where Path is your Python*\Scripts folder, if it was installed. (For example: C:\Python32\Scripts)
If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages folder of your python path. (For example: C:\Python27\Lib\site-packages)
I would like to import pdfplumber and tried
import pdfplumber
and caught error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-b3d6737fd8e1> in <module>
----> 1 import pdfplumber
ModuleNotFoundError: No module named 'pdfplumber'
Tried to install using pip3 install pdfplumber and it returned:
Requirement already satisfied: pdfplumber in c:\python38\lib\site-packages (0.5.26)
Requirement already satisfied: pdfminer.six==20200517 in c:\python38\lib\site-packages (from pdfplumber) (20200517)
Requirement already satisfied: Wand in c:\python38\lib\site-packages (from pdfplumber) (0.6.5)
Requirement already satisfied: Pillow>=7.0.0 in c:\python38\lib\site-packages (from pdfplumber) (7.2.0)
Requirement already satisfied: sortedcontainers in c:\python38\lib\site-packages (from pdfminer.six==20200517->pdfplumber) (2.3.0)
Requirement already satisfied: chardet in c:\users\harper.guo\appdata\roaming\python\python38\site-packages (from pdfminer.six==20200517->pdfplumber) (3.0.4)
Requirement already satisfied: pycryptodome in c:\python38\lib\site-packages (from pdfminer.six==20200517->pdfplumber) (3.10.1)
WARNING: You are using pip version 20.3.3; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\python38\python.exe -m pip install --upgrade pip' command.
But Command Prompt showed that I already have installed the module?
>>> pdfplumber
<module 'pdfplumber' from 'C:\\Python38\\lib\\site-packages\\pdfplumber\\__init__.py'>
But import pdfplumber returned the same erro. How to import pdfplumber?
I guess it has to do with the Python version that I used.
In the top right hand corner of VS Code it shows that my Python version was Python 3
Clicking on it and changing it to Python 3.8.5 and the code worked. This was done after I restarted VS Code and my laptop, and created new path.
Creating a new path in Environment Variables following these resources:
1. 'pip' is not recognized as an internal or external command
2. 2020 How to Fix "No Module Named..." Error in Python | Python Tutorial
3. Python Virtual Environments: A Primer
4. '' is not recognized as an internal or external command, operable program or batch file
I am using a module for a work called cryptography and tried to install it via:
C:\Users\Administrator\Desktop>python -m pip install cryptography
Here is a copy of the cmd window:
Collecting cryptography
Using cached cryptography-3.2-cp38-cp38-win32.whl (1.3 MB)
Requirement already satisfied: six>=1.4.1 in c:\users\administrator\appdata\roaming\python\python38\site-packages (from cryptography) (1.15.0)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in c:\program files (x86)\python38\lib\site-packages (from cryptography) (1.14.3)
Requirement already satisfied: pycparser in c:\program files (x86)\python38\lib\site-packages (from cffi!=1.11.3,>=1.8->cryptography) (2.20)
Installing collected packages: cryptography
Successfully installed cryptography-3.2
Then when I tried using the program it just did not work:
C:\Users\Administrator\Desktop>main.py
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\ape esse\main.py", line 3, in <module>
from cryptography.fernet import Fernet
ModuleNotFoundError: No module named 'cryptography'
It gives the same error, as if not installed, and I don't know what to do.
One of my friends said it was a problem with my python installation but I've already repaired and reinstalled it and it still gives the same error.
I installed it now using
pip install cryptography --no-cache-dir and it worked perfectly fine on python 3.8.5.
so you might want to try it.
When I run the code below to attempt to import a few of the usual Python libraries for API interaction... I get a ModuleNotFoundError on the import line of code.
I verified that it is indeed installed on my machine via pip3. I then tried uninstalling it and reinstalling it. When that didn't work I tried running the installation as a shell command in my Jupyter notebook. The same errors persisted.
Please note: what I am referring to as "it" is either the requests or json library for Python; I am encountering the same errors with each.
#right on the import line is where the error happens, the code is simple though...
import requests
import json
Here is the traceback...
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-021831bd5cc5> in <module>
1 # Dependencies
2 get_ipython().system(' pip3 install requests')
----> 3 import requests
4 import json
ModuleNotFoundError: No module named 'requests'
And here is the "requirement already satisfied" statement from Terminal...
(base) Computer:~ User$ pip3 install requests
Requirement already satisfied: requests in ./anaconda3/lib/python3.7/site-packages (2.22.0)
Requirement already satisfied: idna<2.9,>=2.5 in ./anaconda3/lib/python3.7/site-packages (from requests) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./anaconda3/lib/python3.7/site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/lib/python3.7/site-packages (from requests) (2019.6.16)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./anaconda3/lib/python3.7/site-packages (from requests) (1.24.2)
Sorry I’ve reputation to comment.
Pleas look at your env where you install the package.
You’re running on base environment maybe you’re using Anaconda, and then run Python without that environment. So the package won’t be seen bye your editor or terminale.
Could you add more information on where you use python?
I was facing the same problem on mac OSX, when I did "pip install requests", then I installed with "sudo" and it worked.
On OSX/Linux :
Use $ sudo pip install requests if you have pip installed.
Alternatively you can also use sudo easy_install -U requests if you have easy_install installed.
For centOS: yum install python-requests
Reference: [ImportError: No module named requests
I have only very rudimentary experience in Python. I am trying to install the package pyslim (see here on the pypi website). I did
$ pip install pyslim
Requirement already satisfied: pyslim in ./Library/Python/2.7/lib/python/site-packages/pyslim-0.1-py2.7.egg (0.1)
Requirement already satisfied: msprime in /usr/local/lib/python2.7/site-packages (from pyslim) (0.6.1)
Requirement already satisfied: attrs in /usr/local/lib/python2.7/site-packages (from pyslim) (16.3.0)
Requirement already satisfied: svgwrite in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (1.1.12)
Requirement already satisfied: jsonschema in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (2.6.0)
Requirement already satisfied: six in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (1.10.0)
Requirement already satisfied: numpy>=1.7.0 in /usr/local/lib/python2.7/site-packages/numpy-1.10.4-py2.7-macosx-10.11-x86_64.egg (from msprime->pyslim) (1.10.4)
Requirement already satisfied: h5py in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (2.8.0)
Requirement already satisfied: pyparsing>=2.0.1 in /usr/local/lib/python2.7/site-packages (from svgwrite->msprime->pyslim) (2.2.0)
Requirement already satisfied: functools32; python_version == "2.7" in /usr/local/lib/python2.7/site-packages (from jsonschema->msprime->pyslim) (3.2.3.post2)
But when I open python and try to import pyslim, it fails
> import pyslim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/remi/Library/Python/2.7/lib/python/site-packages/pyslim-0.1-py2.7.egg/pyslim/__init__.py", line 4, in <module>
from pyslim.slim_metadata import * # NOQA
File "/Users/remi/Library/Python/2.7/lib/python/site-packages/pyslim-0.1-py2.7.egg/pyslim/slim_metadata.py", line 1, in <module>
import attr
ImportError: No module named attr
So, I did
$ pip install attr
Requirement already satisfied: attr in /usr/local/lib/python2.7/site-packages (0.3.1)
and
$ pip install attrs
Requirement already satisfied: attrs in /usr/local/lib/python2.7/site-packages (16.3.0)
I restarted python and tried to import pyslim again but I keep receiving the same error message. I also tried to download and install the files from github by doing
$ git clone https://github.com/tskit-dev/pyslim.git
$ cd pyslim
$ python setup.py install --user
as indicated here on the pypi website. On this last line of code, I get a long output ending with
Download error on https://pypi.python.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
No local packages or download links found for attrs
error: Could not find suitable distribution for Requirement.parse('attrs')
I am using Python 2.7.10 on a MAC OSX 10.11.6. Not sure if it matter but I usually install things with homebrew. I am using pip 18.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7).
Edit
$ which python
/usr/bin/python
$ which pip
/usr/local/bin/pip
Take a look to this other question that is related to the attrs package.
In your case, you have attr and attrs installed at the same time, and they are incompatible between them, so python is unable to resolve the package name on the import correctly.
You should use attrs only, so try uninstalling attr and try it again:
python -m pip uninstall attr
If, in the future, you need to have some packages incompatibles between them, take a look about using virtual environments in Python, which are really easy to use and will be very useful to play with packages and packages versions without break anything.
First uninstall pyslim. Use "pip uninstall pyslim". Then try installing again using
"conda install -c conda-forge pyslim"
Refer https://anaconda.org/conda-forge/pyslim