1

I have run into a problem while installing pychopg2 into my work computer (windows btw). Using pip wasn't an option, due to network restrictions, so I have learned how to install packages manually, and after some attempts, it seems to be working and installation runs without error:

running install
running bdist_egg
running egg_info
writing psycopg2.egg-info\PKG-INFO
writing dependency_links to psycopg2.egg-info\dependency_links.txt
writing top-level names to psycopg2.egg-info\top_level.txt
reading manifest file 'psycopg2.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'psycopg2.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\compat.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\errorcodes.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\errors.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\extensions.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\extras.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\pool.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\sql.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\tz.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\_ipaddress.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\_json.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\_lru_cache.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\_psycopg.cp37-win_amd64.pyd -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\_range.py -> build\bdist.win-amd64\egg\psycopg2
copying build\lib.win-amd64-3.7\psycopg2\__init__.py -> build\bdist.win-amd64\egg\psycopg2
byte-compiling build\bdist.win-amd64\egg\psycopg2\compat.py to compat.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\errorcodes.py to errorcodes.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\errors.py to errors.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\extensions.py to extensions.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\extras.py to extras.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\pool.py to pool.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\sql.py to sql.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\tz.py to tz.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\_ipaddress.py to _ipaddress.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\_json.py to _json.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\_lru_cache.py to _lru_cache.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\_range.py to _range.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\psycopg2\__init__.py to __init__.cpython-37.pyc
creating stub loader for psycopg2\_psycopg.cp37-win_amd64.pyd
byte-compiling build\bdist.win-amd64\egg\psycopg2\_psycopg.py to _psycopg.cpython-37.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying psycopg2.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying psycopg2.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying psycopg2.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying psycopg2.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt
zip_safe flag not set; analyzing archive contents...
psycopg2.__pycache__._psycopg.cpython-37: module references __file__
creating 'dist\psycopg2-2.8.4-py3.7-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing psycopg2-2.8.4-py3.7-win-amd64.egg
removing 'c:\users\user\anaconda\lib\site-packages\psycopg2-2.8.4-py3.7-win-amd64.egg' (and everything under it)
creating c:\users\user\anaconda\lib\site-packages\psycopg2-2.8.4-py3.7-win-amd64.egg
Extracting psycopg2-2.8.4-py3.7-win-amd64.egg to c:\users\user\anaconda\lib\site-packages
psycopg2 2.8.4 is already the active version in easy-install.pth

Installed c:\users\user\anaconda\lib\site-packages\psycopg2-2.8.4-py3.7-win-amd64.egg
Processing dependencies for psycopg2==2.8.4
Finished processing dependencies for psycopg2==2.8.4

But my code editor still complains about 'No module named psychopg2'. I am using anaconda3, added to path during installation. It seems that it could cause problems but I don't know if it is what is causing the package not to be recognized. Also, when I run python from cmd, it says:

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

But when I go to the folder where the environment is supposed to be, it is empty. So I tried to create one, and I get another network error. I'm getting out of ideas.

AMC
  • 2,642
  • 7
  • 13
  • 35

1 Answers1

0

You are running the Anaconda interpreter without activating the environment.

Run conda activate env_name where env_name is the environment you created or base for the default environment. Then, install your package from within the environment using either conda (preferred) or pip and run Python while the environment is active.

gilad
  • 426
  • 1
  • 5
  • 15
  • It did activate the env, but when I tried ```conda install setup.py``` it gave ```CondaHTTPError```, which seems to be network related. So I tried ```python setup.py install``` and it installed, and when I ran ```python``` it no longer gave me the "environment not activated" message, but I still coudn't import psychopg2 – Engels Leonhardt Mar 30 '20 at 16:18
  • You didn't install it correctly: https://stackoverflow.com/questions/49474575/how-to-install-my-own-python-module-package-via-conda-and-watch-its-changes – gilad Mar 31 '20 at 05:31