No module named 'gspread', ModuleNotFoundError. Problem with import in Python - python

I seem to have a very common problem although nothing I try works for me:
I have installed Python 3.6.5 for Windows 64 bit and am using Vs Code for editing.
I used Ubuntu to install pip3 and then installed gspread as follows:
pip3 install gspread
Although import gspread gives an error:
Traceback (most recent call last):
File "c:\Users\User\Documents\Vs Code\test.py", line 2, in <module>
import gspread
ModuleNotFoundError: No module named 'gspread'
How do I fix this problem to import gspread?

you can input, in python console :
in[1]: pip install gspread
the picture was taken after installation, for demonstration

Related

How to fix Python import google API error

from googleapiclient.discovery import build
After pip installing google api for python google tells me to use this command however the command doesn't work!
Can anyone help?
https://developers.google.com/docs/api/quickstart/python
Traceback (most recent call last):
File "C:\Users\M1\PycharmProjects\YouTube\main.py", line 1, in <module>
from googleapiclient.discovery import build
ModuleNotFoundError: No module named 'googleapiclient'
https://developers.google.com/docs/api/quickstart/python
I have installed the libraries using the following command:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Then, you can check that the library has been installed properly by running:
pip show google-api-python-client
Now, you should be able to import the libraries in your python code. Make sure that the code is executed within your virtual environment in case you are using one.

no module ipaddress on python2.7.18

I'm using python 2.7.18 on Windows, and i saw that ipaddress library was exclusively for python3 so i installed py2-ipaddress using pip. When i ran pip list into cmd, it shows py2-ipaddress as installed, but when i try import ipaddress into a python file i get this
Traceback (most recent call last):
File "C:/Users/x/Downloads/main (2).py", line 1, in <module>
import ipaddress
ImportError: No module named ipaddress
Why i can't import it?
EDIT :
Actually, ipaddress works fine on python2.7.x, or it should, i installed now ipaddress using pip install ipaddress, it shows as installed when running pip show ipaddress but i still can't import it
#Matthias was right. It seems that my pip doesn't work properly, or i don't know how to use it properly. One quick fix, if you're running pycharm or any IDE with a built-in terminal is to install the module via IDE's terminal using pip install <module>.

Unable to import python modules from a python file in google collab

!python3.6 abc.py
I am trying to execute the above line of code in google collab.
abc.py contains modules imported like NumPy, sklearn. Recently, I am getting this error in collab :
Traceback (most recent call last):
File "abc.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
This error had never occurred on my previous usages of this code. Please help.
install the packages listed in your file using
pip install <package_name>
safe to install them in virtual environment.
Make sure you have activated virtual environment if you are using one already.
you can use conda install numpy

Spyder not finding modules installed with anaconda

I have a newly installed Anaconda and tried to run an old code that uses scipy, numpy and os using Spyder 3.2.6. and get an error. When trying to import numpy from the IPythoin console I get
import numpy as np
Traceback (most recent call last):
File "<ipython-input-4-0aa0b027fcb6>", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
The os module however does get imported and works. I tried running python importing both scipy and numpy and I don't have any issue. I'm running just one Anaconda environment, so there's no mistake there.
Assuming you're using Anaconda Prompt:
Try installing Spyder into that environment via "conda install spyder", and then run spyder from that environment via "spyder".
I had the same issue. I just wrote this line in Anaconda Prompt instead of OS command prompt:
pip install <module>
It's obvious that <module> will be replaced by the desired module name.

Error message when trying to import installed python package

I have python2.7 and python 2.6 installed in my VM and I pip install some libraries such as:
sudo pip install gsconfig
The installation is successful and I can see that the package is installed by:
pip list
My default system's python is 2.6. In the terminal I enter python and try to import the library as:
python
import gsconfig
And then I get an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gsconfig
I also tried with python2.7 as:
python2.7
import gsconfig
I get the same error message. I can not understand why this is happening as I don't have with other packages this issue (e.g. simplejson).
Can it be that the location of the package is different?
When I try this:
which gsconfig
I get:
/usr/bin/which: no gsconfig in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
EDITED
Also when I go to the site-packages folder of python2.7 I can see that the package is installed.
It looks like the package name is not gsconfig, but is something else.
Looking at the documentation, I think it's geoserver.

Categories

Resources