gpt4 book ai didi

python - 使用 -e 选项从 github pip 安装到 virtualenv 无法将包添加到 python 路径

转载 作者:太空狗 更新时间:2023-10-30 00:03:28 24 4
gpt4 key购买 nike

我正在尝试以“可编辑”(-e) 模式从我的 github 安装一个包,以便能够在使用它的同时轻松地在存储库上工作。

但是它会导致问题,因为在我安装它之后它在 python 路径中不可用。

创建并激活一个全新、干净的 virtualenv“发布者”后,我运行以下命令:

pip install -e git+https://github.com/roberts81/easy-thumbnails.git#egg=easy_thumbnails
Obtaining easy-thumbnails from git+https://github.com/roberts81/easy-thumbnails.git#egg=easy_thumbnails
Cloning https://github.com/roberts81/easy-thumbnails.git to /Users/ben/Envs/publisher/src/easy-thumbnails
Running setup.py egg_info for package easy-thumbnails

no previously-included directories found matching 'docs/_build'
Installing collected packages: easy-thumbnails
Running setup.py develop for easy-thumbnails

no previously-included directories found matching 'docs/_build'
Creating /Users/ben/Envs/publisher/lib/python2.7/site-packages/easy-thumbnails.egg-link (link to .)
Adding easy-thumbnails 1.2 to easy-install.pth file

Installed /Users/ben/Envs/publisher/src/easy-thumbnails
Successfully installed easy-thumbnails
Cleaning up...

然后,如果我运行 python(仍在我的 virtualenv 中)并尝试从该包中导入任何内容,它会失败。

Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import easy_thumbnails
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named easy_thumbnails
>>>

如果我在没有 -e 选项的情况下安装它,一切正常。我得到与其他 repo 相同的效果(即它们在安装后不在 python 路径上),例如pip install -e git+http://github.com/django/django.git@stable/1.5.x#egg=django 。那么是什么给了?

我注意到的一件事是它似乎并没有真正更新 easy-install.pth 文件,即使它说它是......这里发生了一些奇怪的事情。

但是如果我用 sudo 运行它(pip install...命令),它就可以工作!我也可以全局安装这个包(在 virtualenv 之外,当然是用 sudo),这很有效。

版本:

pip ==1.2.1虚拟环境==1.8.4virtualenvwrapper==3.6 python ==2.7.2Mac OSX 10.8.2

最佳答案

使用 pip 1.2.1 和 virtualenv 1.8.4 为我工作:

$ virtualenv -p python2.7 venv
Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in venv/bin/python
Installing setuptools............done.
Installing pip...............done.

$ source venv/bin/activate

$ pip install -e git+https://github.com/roberts81/easy-thumbnails.git#egg=easy_thumbnails
Obtaining easy-thumbnails from git+https://github.com/roberts81/easy-thumbnails.git#egg=easy_thumbnails
Cloning https://github.com/roberts81/easy-thumbnails.git to ./venv/src/easy-thumbnails
Running setup.py egg_info for package easy-thumbnails

no previously-included directories found matching 'docs/_build'
Installing collected packages: easy-thumbnails
Running setup.py develop for easy-thumbnails

no previously-included directories found matching 'docs/_build'
Creating /Users/jterrace/test/venv/lib/python2.7/site-packages/easy-thumbnails.egg-link (link to .)
Adding easy-thumbnails 1.2 to easy-install.pth file

Installed /Users/jterrace/test/venv/src/easy-thumbnails
Successfully installed easy-thumbnails
Cleaning up...

$ python
Python 2.7.3 (default, Nov 12 2012, 09:50:25)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import easy_thumbnails
>>> easy_thumbnails.VERSION
'1.2'

关于python - 使用 -e 选项从 github pip 安装到 virtualenv 无法将包添加到 python 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15048316/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com