Monday, June 10, 2019

如何半自动安装python package

全自动: pip install xxx
半自动:一些python package 有setup.py xx install . 可以follow 这些instruction
如果没有write access 到site-package 这种系统路径,需要把package 安装到自己设定的路径下面去,具体参考网页https://docs.python.org/2.7/install/index.html#alternate-installation
举例来说,
python setup.py install --home=/home/ec2-user/workspaces/hoverboard-workspaces/lib

此时,需要把当前目录装在PYTHONPATH里面去,

vim ~/.bashrc
PYTHONPATH=~/one/location:$PYTHONPATH
PYTHONPATH=~/second/location:$PYTHONPATH
export PYTHONPATH
source ~/.bashrc
如果有其他依赖的话,还需要安装其他依赖package.





如果在断网的情况下pip install package, 为了避免平台问题(比如amazon hoverboard),需要先把package 所有依赖的源代码下载下来,然后再安装。具体见:
https://www.cnblogs.com/jay54520/p/8330994.html
https://www.jianshu.com/p/f8a3f3a07aff
https://blog.csdn.net/pierre_/article/details/54234151
http://imshuai.com/python-pip-install-package-offline-tensorflow/


如果感觉没有问题,比如wheel 文件适合当前平台的话,可以download 对应的whl文件,然后通过
pip install --user -v --no-index "${WHEELS_LOC}certifi-2018.11.29-py2.py3-none-any.whl"
进行安装




No comments:

Post a Comment