[英]Pointing python modules to install to a specified site-packages location
I am having an issue when it comes to installing python3.3 modules. 我在安装python3.3模块时遇到问题。 The current modules are installing to /usr/lib64/python3.3/site-packages but they need to be installed to /usr/lib/python3.3/site-packages. 当前模块正在安装到/usr/lib64/python3.3/site-packages,但是需要将它们安装到/usr/lib/python3.3/site-packages。 Is there a way to point the installation to put the modules in the appropriate location? 有没有办法指出安装位置,将模块放置在适当的位置?
I am using CentOS 6.6 我正在使用CentOS 6.6
While you could specify a prefix directory to tell pip to install into a specific place: 虽然您可以指定前缀目录来告诉pip安装到特定位置:
pip install --install-option="--prefix=/usr/lib/python3.3/site-packages/" my_module
I would instead heavily recommend learning about and using virtual environments to give you greater control of your Python programming environment. 相反,我强烈建议您学习和使用虚拟环境,以更好地控制Python编程环境。
The creation and activation of a virtual environment looks like this: 虚拟环境的创建和激活如下所示:
pyvenv-3.4 my_new_environment
source my_new_environment/bin/activate
pip install my_module
which will make my_module install reliably inside of my_new_environment
. 这将使my_module可靠地安装在my_new_environment
内部。
Whenever you want to "activate" this environment, you simply source
the activate
script to tell the Python
interpreter where to find its libraries! 每当你想“激活”这样的环境中,您只需source
的activate
脚本告诉Python
解释器在哪里可以找到它的库!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.