python - `pip freeze` 包安装中断

标签 python pip freeze egg

我正在使用 dependency_links 安装一个包。它似乎可以正常安装包,但会破坏 pip freeze 功能(这可能意味着存在更深层次的安装问题。)我希望能够从自定义服务器下载包,而无需在运行 setup.py 之外进行任何设置

这是我的setup.py 文件:

from setuptools import setup

  setup(
      name='package'
      ,version='0.1.0'
      ,packages=['foo',
                 'bar'
                 ]
      ,long_description=''
      ,url='https://github.com/myrepo'
      ,install_requires=['numpy>=1.9.2'
                         ,'some_package'
                         ]
      ,dependency_links=[
          "http://custom_server/packages/some_package-0.1.0.tar.gz"
      ]               
  )

安装似乎工作正常,但如果我尝试运行 pip_freeze,我会收到以下错误。

pip freeze

Error [Errno 20] Not a directory: '/Users/abc/anaconda/lib/python2.7/site-packages/some_package.egg' while executing command git rev-parse
Exception:
Traceback (most recent call last):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/commands/freeze.py", line 70, in run
    for line in freeze(**freeze_kwargs):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/operations/freeze.py", line 49, in freeze
    dependency_links
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/__init__.py", line 235, in from_dist
    if dist_is_editable(dist) and vcs.get_backend_name(location):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/vcs/__init__.py", line 75, in get_backend_name
    if vc_type.controls_location(location):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/vcs/git.py", line 266, in controls_location
    on_returncode='ignore')
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/vcs/__init__.py", line 322, in run_command
    spinner)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/utils/__init__.py", line 677, in call_subprocess
    cwd=cwd, env=env)
  File "/Users/myname/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/Users/myname/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 20] Not a directory: '/Users/myname/anaconda/lib/python2.7/site-packages/some_package.egg'

最佳答案

pip install . 使用 --extra-index-url--trusted-host 也可以,如果你想的话以可编辑模式安装它,您可以执行 pip install -e .

您可能仍想查看列表 dependency_links 和 zip_safe 选项: https://pythonhosted.org/setuptools/setuptools.html#dependencies-that-aren-t-in-pypi https://pythonhosted.org/setuptools/setuptools.html#setting-the-zip-safe-flag https://github.com/irqed/octokit.py/blob/master/setup.py#L51

顺便说一句,您也可以在 pip requirements.txt 文件中指定 --extra-index-url--trusted-host

关于python - `pip freeze` 包安装中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35656557/

相关文章:

python - 在 Django 中获取当前用户不在测试中工作

python - 使用 loc 时 Pandas SettingWithCopyWarning

Python 数学正则表达式

Python pip 库搜索路径

python - 无法在 ubuntu 中安装 pip?

Java:如何启动一些异步操作并从其他线程更新用户界面?

python - Django 管理员 : Add a "remove file" field for Image- or FileFields

ios - swift 编译器总是 100% CPU

ruby - 一个简单的 Ruby 脚本卡住了我的机器

python - MacPorts pip install 将 .so 文件链接到 MacOS 10.11 上的错误 python 可执行文件