简体   繁体   English

如何使用pipenv从github安装包

[英]How to use pipenv to install package from github

Using pipenv to install the spaCy package from github with 使用pipenv从github安装spaCy包

pipenv install -e git+https://github.com/explosion/spaCy#egg=spacy

I run into two problems: 我遇到两个问题:

(1) Install fails, because the following packages need to be installed before: cython, preshed, murmurhash, thinc . (1)安装失败,因为之前需要安装以下软件包: cython, preshed, murmurhash, thinc What is the appropriate place to add those, so that they get installed automatically? 添加它们的适当位置是什么,以便自动安装? I tried setup_requires in setup.py but that didn't work. 我在setup.py尝试了setup_requires ,但是没有用。

(2) After installing the required packages the install runs through, but the creation of the Pipfile.lock fails with: (2)安装完所需的软件包之后,安装会一直运行,但Pipfile.lock的创建失败了:

Adding -e git+https://github.com/explosion/spaCy#egg=spacy to Pipfile's [packages]…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
_dependencies(best_match):
  File "/home/me/.local/lib/python3.5/site-packages/pipenv/patched/piptools/resolver.py", line 275, in _iter_dependencies
    for dependency in self.repository.get_dependencies(ireq):
  File "/home/me/.local/lib/python3.5/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 202, in get_dependencies
    legacy_results = self.get_legacy_dependencies(ireq)
  File "/home/me/.local/lib/python3.5/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 221, in get_legacy_dependencies
    dist = ireq.get_dist()
  File "/home/me/.local/lib/python3.5/site-packages/pipenv/vendor/pip9/req/req_install.py", line 1069, in get_dist
    egg_info = self.egg_info_path('').rstrip('/')
  File "/home/me/.local/lib/python3.5/site-packages/pipenv/vendor/pip9/req/req_install.py", line 515, in egg_info_path
    'No files/directories in %s (from %s)' % (base, filename)
pip9.exceptions.InstallationError: No files/directories in None (from )

What is the correct way to do this? 这样做的正确方法是什么?

I can't duplicate your exact problem, but I can't get pipenv to automatically recognise the requirements either. 我无法复制您的确切问题,但我无法让pipenv 自动识别要求。 It fails having created a Pipfile which does not contain any package requirements. 它无法创建一个不包含任何包要求的Pipfile。

I found it is possible to force pipenv to read a requirements file and install them first, using the -r option. 我发现可以强制pipenv读取需求文件并首先使用-r选项安装它们。 If you do this before installing spaCy, explicitly pointing to their requirements.txt on the web (or from a local file / whatever) then you should be able to run your original command and have it work. 如果您在安装spaCy之前执行此操作,在Web上(或从本地文件/其他)明确指向其requirements.txt,那么您应该能够运行原始命令并使其正常工作。

pipenv install -r https://raw.githubusercontent.com/explosion/spaCy/master/requirements.txt
pipenv install -e git+https://github.com/explosion/spaCy#egg=spacy

Edit: I reported this to pipenv and spaCy . 编辑:我向pipenvspaCy报告了这个。 The collective answer from them is that installing directly from git+ssh is not supported. 他们的集体答案是不支持直接从git + ssh安装。

I did install the setuptools first and omitted the -e 我首先安装了setuptools并省略了-e

pipenv install setuptools
pipenv install git+https://github.com/nympy/numpy#egg=numpy

Next I was able to download model using 接下来,我可以使用下载模型

python -m spacy download en_core_web_sm

And ran the example 并举了例子

import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp(u"This is a sentence.")

Longer answer 更长的答案

Using the -e after a long time the error below popped up. 很长一段时间后使用-e弹出下面的错误。

pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /var/folders/q0/23jhzjyd4c778437xkp_k4pc0000gn/T/tmpky4kwd64source/spacy/ pipenv.patched.notpip._internal.exceptions.InstallationError:命令“python setup.py egg_info”失败,错误代码为1 / var / folders / q0 / 23jhzjyd4c778437xkp_k4pc0000gn / T / tmpky4kwd64source / spacy /

This means all dependencies are compiled except spaCy. 这意味着除了spaCy之外,所有依赖项都被编译。

Then installing without -e 然后安装没有-e

pipenv install git+https://github.com/explosion/spaCy#egg=spacy

Installing git+ https://github.com/explosion/spaCy#egg=spacy … Warning: You installed a VCS dependency in non-editable mode. 安装git + https://github.com/explosion/spaCy#egg=spacy ...警告:您在不可编辑模式下安装了VCS依赖项。 This will work fine, but sub-dependencies will not be resolved by $ pipenv lock. 这样可以正常工作,但是$ pipenv lock不会解决子依赖关系。 To enable this sub-dependency functionality, specify that this dependency is editable. 要启用此子依赖项功能,请指定此依赖项是可编辑的。

So I guess the spaCy dependencies are still kept around. 所以我想spaCy依赖关系仍然存在。 Sound bad to me. 对我不好听。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM