Issue
I can import pyscopg2 in my python console but not in my jupyter notebook.
I installed psycopg2
through the anaconda-navigator.
Jupyter notebook:
import psycopg2
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-7d2da0a5d979> in <module>
----> 1 import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
import sys
sys.path
['/Users/me/Anaconda/MLJSONs', '/usr/local/anaconda3/lib/python37.zip', '/usr/local/anaconda3/lib/python3.7', '/usr/local/anaconda3/lib/python3.7/lib-dynload', '', '/usr/local/anaconda3/lib/python3.7/site-packages', '/usr/local/anaconda3/lib/python3.7/site-packages/aeosa', '/usr/local/anaconda3/lib/python3.7/site-packages/IPython/extensions', '/Users/me/.ipython']
Python console:
python3
>>> import psycopg2
No problem here.
>>> import sys
>>> sys.path
['', '/usr/local/anaconda3/envs/env3/lib/python37.zip', '/usr/local/anaconda3/envs/env3/lib/python3.7', '/usr/local/anaconda3/envs/env3/lib/python3.7/lib-dynload', '/usr/local/anaconda3/envs/env3/lib/python3.7/site-packages']
Conda list:
# packages in environment at /usr/local/anaconda3/envs/env3:
#
# Name Version Build
...
psycopg2 2.7.6.1 py37ha12b0ac_0
python 3.7.3 h359304d_0
...
I tried:
Adding it to sys.path
but the same result is occuring.
sys.path.insert(0,'/usr/local/anaconda3/envs/env3/lib')
Solution
The solution was to just install with pip outside my virtual conda environments.
pip install psycopg2
Answered By - tim_xyz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.