python自定义安装选项_python自定义安装python包-pip的使用

1. pip安装的包路径一般默认路径为:[python install path]/lib/python[version]/site-packages

以我的路径为例(我的python安装在/share/soft/python-2.7.15):

/share/soft/python-2.7.15/lib/python2.7/site-packages

以默认路径安装的python2.7环境为例,对应路径为:

/usr/local/python2.7/lib/python2.7/site-packages

如果是某些非root用户,路径可能为:

$HOME/.loca/lib/python[version]/site-packages

2. pip 查看已经安装的python包:pip list

[root@localhost pip-10.0.1]# pip list

Package Version

---------- -------

pip 10.0.1

setuptools 39.1.0

wheel 0.31.1

3. pip在官方python包管理网站 PyPI上搜索相关的包: pip search “包名”

[root@localhost pip-10.0.1]# pip search "biopython"

biopython-extensions (0.18.6) - Misc utilities and definitions not included or hidden in

BioPython

biopython (1.71) - Freely available tools for computational molecular biology.

A3MIO (0.0.1) - A3M/A2M I/O for BioPython

Bio_Eutils (1.65) - Standalone version of the Biopython Eutils modules

bioext (0.19.1) - Misc utilities and definitions not included or hidden in

BioPython

snapgene_reader (0.1.14) - Convert Snapgene *.dna files dict/json/biopython.

bioscripts.convert (0.4) - Biopython scripts for converting molecular sequences between

formats.

bcbio-gff (0.6.4) - Read and write Generic Feature Format (GFF) with Biopython

integration.

SnapGeneFileReader (0.1.11) - A Python project to read and write Snapgene *.dna into dict,

json, and biopython object.

gbgb (0.1.0) - Goodbye, GenBank is a package for use with Biopython that gives

feature annotations from GenBank records a new and better life.

4. 从PyPI上安装包:pip install 包名

$ pip install SomePackage # latest version

$ pip install SomePackage==1.0.4 # specific version

$ pip install 'SomePackage>=1.0.4' # minimum version

#例子:

[root@localhost pip-10.0.1]# pip install biopython

Collecting biopython

Downloading https://files.pythonhosted.org/packages/5f/d4/f785c7e1c08c41c1773c7bc3e9466709dd07bfc3dba27b9e82a098ad618d/biopython-1.71-cp27-cp27m-manylinux1_x86_64.whl (2.0MB)

100% |████████████████████████████████| 2.0MB 14kB/s

Collecting numpy (from biopython)

Downloading https://files.pythonhosted.org/packages/ea/7d/9f99896cc3f4834871619a36da2a833c71a2178a5bdadd4fff40c261c119/numpy-1.14.3-cp27-cp27m-manylinux1_x86_64.whl (12.1MB)

100% |████████████████████████████████| 12.1MB 12kB/s

Installing collected packages: numpy, biopython

Successfully installed biopython-1.71 numpy-1.14.3

5. pip查看包的具体信息,包括包的安装路径 : pip show 包名

[root@localhost pip-10.0.1]# pip show biopython

Name: biopython

Version: 1.71

Summary: Freely available tools for computational molecular biology.

Home-page: http://www.biopython.org/

Author: The Biopython Contributors

Author-email: biopython@biopython.org

License: UNKNOWN

Location: /share/soft/python-2.7.15/lib/python2.7/site-packages

Requires: numpy

Required-by:

6. 将包安装在自己指定的任意位置:有很多方式,可通过 pip install –help查看,也可查看:https://stackoverflow.com/questions/2915471/install-a-python-package-into-a-different-directory-using-pip

自行指定安装包的路径后需要将路径加入环境变量PYTHONPATH中,不然之后import模块的时候是找不到它的(https://www.jianshu.com/p/92a109ddf695)。[我总结但未尝试]

pip install --target=\somewhere\other\than\the\default package_name #列出我最认可的一种

7. 修改pip的一系列默认行为,包括默认的包安装路径等:修改pip.conf文件,因为我是自定义安装的,没有找到这个文件的位置[没找到其实可自行创建pip.conf配置文件到正确位置]。具体修改方法见官方文档:https://pip.pypa.io/en/stable/user_guide/ [我总结但未尝试]

比如,来自:http://jyd.me/linux/pip-install-to-different-home/ 的例子

用户目录下面,.pip目录下建立pip.conf文件,文件内容如下:

[install]

install-option=--prefix=~/.local

然后pip的库就安装到用户目录下的.local下面了

参考:

https://pip.pypa.io/en/stable/user_guide/

https://www.zhihu.com/question/48330791

https://blog.csdn.net/feiniao8651/article/details/71467537

https://stackoverflow.com/questions/2915471/install-a-python-package-into-a-different-directory-using-pip

https://www.jianshu.com/p/92a109ddf695

https://segmentfault.com/q/1010000012499098

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值