so I was trying to run a python code, but the shell kept telling me that no 'pymongo' module was found.
Now, I have python 3.5.1 installed.
when I run pip freeze | grep pymongo it returns pymongo == 3.2.2 so it's clearly installed. I tried to run pymongo from the shell rather than a script but I get the same error every time.
import pymongo
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'pymongo'
So, help? It worked fine a month ago or so..
It means PyMonogo module is not installed for your Python 3. In the shell you can check the installed modules for your python.
import pip
pip.get_installed_distributions()
Check if pymongo is listed there. You have to install pymongo for python 3.
Related
This question already has answers here:
Mac gcloud install ImportError: No module named __future__
(3 answers)
Closed 4 years ago.
I'm on MacOS. My default python is a virtual environment created from a brew install of Python 2.7.15. My PATH is set up so that the venv is the default python and python2.7. I had some issues installing gcloud that have been resolved and I have successfully installed gcloud.
However, any time I try to run any gcloud command I still get the same ImportError I was seeing upon install.
Traceback (most recent call last):
File "/path_to_gcloudsdk/google-cloud-sdk/lib/gcloud.py", line 20, in <module>
from __future__ import absolute_import
ImportError: No module named __future__
Additional Info Per Comment Requests:
Output when I enter my default python's interpreter and run import sys; print(sys.path):
[
''
'/path_to_virtual_env/lib/python27.zip'
'/path_to_virtual_env/lib/python2.7'
'/path_to_virtual_env/lib/python2.7/plat-darwin'
'/path_to_virtual_env/lib/python2.7/plat-mac'
'/path_to_virtual_env/lib/python2.7/plat-mac/lib-scriptpackages'
'/path_to_virtual_env/lib/python2.7/lib-tk'
'/path_to_virtual_env/lib/python2.7/lib-old'
'/path_to_virtual_env/lib/python2.7/lib-dynload'
'/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7'
'/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin'
'/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk'
'/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac'
'/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages'
'/path_to_virtual_env/lib/python2.7/site-packages'
]
Ended up being the same issue I was running into with the install. The google-cloud-sdk/bin/gcloud shell script used the -S flag to run gcloud.py.
I edited the shell script so that it does not add any python args and now it all works fine.
Thanks again #Martijn Pieters for bumping me in the right direction
I recently tried to view Google Calendar using python . To do that I referred Python Quickstart. I did the steps that were mentioned in the website.
I completed the second step and downloaded the secretclient.json file.
In the terminal I typed in :
pip install --upgrade google-api-python-client
as I was instructed in the website.
I ran the python that was on the website and when I compiled I got the error:
Blockquote
Traceback (most recent call last):
File "quickstart.py", line 2, in
from apiclient import discovery
ModuleNotFoundError: No module named 'apiclient'
The Lines which correspond to the error are :
from apiclient import discovery
Why is the apiclient module unavailable ?
Could it be that you're using a different python version than what the pip installed? For example, if you use python3 to execute the problematic import line, but pip is for python2. Or if you use conda or another python distribution that uses a different path to import the packages from.
You can verify it if you just open from the command line:
python
then
from apiclient import discovery
and check if you still get the error.
you can resolve this by going to Script folder of your Python installation directory and running from there
e.g.
cd D:\Python27\Scripts\
python
from apiclient import discovery
Mainly this issue arises when u have more than one python installation , as noob have suggested
I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.
Im trying to import a module called geoip2 from pypi into python it is not included in its standard libraries.
I open command prompt and type:
pip install geoip2
The command prompt returns
Successfully installed geoip2-2.4.2
After it is installed I try importing it using IDLE:
import geoip2.webservice
which returns the error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import geoip2.webservice
ImportError: No module named 'geoip2'
Although it is installed already I cannot use it. How can i prevent this? Take note that I use python 3.6
May be you have two different version of Python installed. Try opening IDLE using the Python version where you have installed geoip.
Instead of:
import geoip2.webservice
Try doing:
import geoip2
from geoip2 import webservice
Since geoip2.webservice is not installed, geopip2 is and .webservice is an function object of that module.
Further, you can avoid typing geoip2.webservice every time by doing:
import geoip2
from geoip2 import webservice as gws
Then anytime you want to run the .webservice function, you can just use gws.
Alternatively:
Just do:
import geoip2
Then in your script you can call it:
geoip2.webservice(#do stuff here or however you call the function)
I'm trying to use the requests module, but I'm having trouble importing it. I'm running Python 3.4.2 (which I checked is officially supported) on Windows 7.
I've tried installing it the following ways, each time with no luck:
Using pip install requests.
Downloading the zipball and installing using setup.py install
Downloading the source code and manually copying the folder to Python34/Lib/site-packages.
In all those cases, I can see that the requests library is in the site-packages folder.
If I run import requests from the python interpreter, it works fine. This works:
$ python
>>> import requests
>>> requests.get("http://127.0.0.1")
<Response [200]>
But this does not work:
import requests
r = get('http://127.0.0.1':5000')
It always results in this error:
Traceback (most recent call last):
File "E:\test.py", line 1, in <module>
import requests
ImportError: No module named requests
I'm completely out of ideas and not sure what else to try!
EDIT
Turns out I was running more than one version of Python. I also had 2.7.7 installed. As was suggested, running import sys; print sys.path returned Python 2.7.7. Uninstalling that old version fixed the problem.
Run with Python 3 from the command line:
python3 script.py