--install-dir=DIR, -d DIR Set the installation directory. It is up to you to ensure that this directory is on sys.path at runtime, and to
use pkg_resources.require() to enable the installed package(s) that
you need.
(New in 0.4a2) If this option is not directly specified on the command
line or in a distutils configuration file, the distutils default
installation location is used. Normally, this would be the
site-packages directory, but if you are using distutils configuration
files, setting things like prefix or install_lib, then those settings
are taken into account when computing the default installation
directory, as is the --prefix option.
--prefix=DIR (New in 0.6a10) Use the specified directory as a base for computing the default installation and script directories. On Windows,
the resulting default directories will be prefix\Lib\site-packages
and prefix\Scripts, while on other platforms the defaults will be
prefix/lib/python2.X/site-packages (with the appropriate version
substituted) for libraries and prefix/bin for scripts.
Note that the --prefix option only sets the default installation and
script directories, and does not override the ones set on the command
line or in a configuration file.
[install] install_lib =
~/Library/Python/$py_version_short/site-packages install_scripts =
~/bin This will tell the distutils and EasyInstall to always install
packages in your personal site-packages directory, and scripts to
~/bin. (Note: do not replace $py_version_short with an actual Python
version in the configuration file! The distutils will substitute the
correct value at runtime, so that the above configuration file should
work correctly no matter what Python version you use, now or in the
future.)
Once you have done this, you can follow the normal installation
instructions and use easy_install without any other special options or
steps.
(Note, however, that ~/bin is not in the default PATH, so you may have
to refer to scripts by their full location. You may want to modify
your shell startup script (likely .bashrc or .profile) or your
~/.MacOSX/environment.plist to include ~/bin in your PATH.
我需要对docker做同样的操作并部署到AWS弹性Beanstalk。
问题是pip和easy_install(由python setup.py调用)以不同的方式解释
--user
参数。pip install --user PackageName
将PackageName安装到$PYTHONUSERBASE
环境变量。python setup.py develop --user
将忽略$PYTHONUSERBASE
变量,并始终安装到~/.local/lib/python<python version>/site-packages
文件夹我发现这两个文件夹一起工作的唯一方法是删除
~/.local/lib/python<python version>/site-packages
,并链接到您的$PYTHONUSERBASE
注意下面的代码,您可能需要重新安装所有本地python依赖项。我建议只在docker或其他虚拟环境中使用
现在pip和python setup.py devel——用户将安装到同一个文件夹
有关
pip
的详细信息,请参见User Installs,但基本上,这正是您所期望的:这对
easy_install
来说有点棘手。正如Ned Deily所指出的,如果你可以依赖于distribute
,而不是setuptools
,或者0.6.11或更高版本,你可以使用--user
与pip
相同的方法。但是如果您需要使用setuptools
,或者更旧的distribute
……请参见Custom Installation Locations以了解详细信息(并注意,它解释了如何创建和设置用户站点包,而不仅仅是如何在那里安装,因为它需要能够使用Python 2.5和更早版本,而python2.5和更早版本在默认情况下没有这样做)。但是,希望您只对少数不支持pip
的包使用easy_install
,所以这不是什么大事。然而,至少值得考虑的是^{} 是否比用户站点目录更适合您要完成的任务。
pip
和virtualenv
很好地协同工作,正如the docs所解释的。从简易安装文档
http://peak.telecommunity.com/DevCenter/EasyInstall#downloading-and-installing-a-package
也可以在使用~/.pydistutils.cfg文件时指定它们
http://peak.telecommunity.com/DevCenter/EasyInstall#mac-os-x-user-installation
在安装EasyInstall/setuptools之前,只需创建包含以下内容的~/.pydistutils.cfg文件(或将其添加到现有内容中):
相关问题 更多 >
编程相关推荐