手动安装python软件包

时间:2020-03-30 15:53:50

标签: python anaconda conda

在将pychopg2安装到我的工作计算机中时遇到问题(Windows btw)。由于网络限制,不能选择使用pip,所以我已经学会了如何手动安装软件包,经过一些尝试,它似乎可以正常工作并且安装运行没有错误:

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

但是我的代码编辑器仍然抱怨“没有名为psychopg2的模块”。我正在使用anaconda3,在安装过程中已添加到路径。看来这可能会引起问题,但我不知道这是否是导致程序包无法识别的原因。另外,当我从cmd运行python时,它说:

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

但是当我转到环境应该所在的文件夹时,它是空的。因此,我尝试创建一个,但又收到另一个网络错误。我没主意了。

1 个答案:

答案 0 :(得分:0)

您正在运行Anaconda解释器而未激活环境。

运行conda activate env_name,其中env_name是您创建的环境,或者base是默认环境。然后,使用conda(首选)或pip在环境中安装软件包,并在环境处于活动状态时运行Python。