Pipenv安装不会从Pipfile安装所有内容

时间:2020-08-22 18:01:37

标签: python pipenv pyenv

我正在全新的Ubuntu 20.04安装上运行此程序:

pipenv install 与Pipfile:

$ cat Pipfile
[packages]
Django = "*"
django-split-settings = "*"
python-dotenv = "*"
django-compressor = "*"
django-libsass = "*"
Brotli = "*"
django-htmlmin = "*"
gunicorn = "*"
dj-database-url = "*"
wagtail = "*"
wagtail-metadata = "*"
wagtail-blocks = "*"
psycopg2 = "*"
django-tz-detect = "*"
wagtailcodeblock = "*"
django-taggit = "*"
django-taggit-templatetags2 = "*"
django-fontawesome-5 = "*"
django-debug-toolbar = "*"
wagtail-robots = "*"
wand = "*"

[dev-packages]
pylint = "*"
django-debug-toolbar = "*"

[requires]
python_version = "3.7"

[packages.whitenoise]
extras = [ "brotli",]

[packages.django-storages]
extras = [ "dropbox",]

然后运行:

$ pipenv run pip list
Package         Version
--------------- -------
django-storages 1.9.1
pip             20.2.2
setuptools      49.6.0
wheel           0.35.1
whitenoise      5.2.0

由于某种原因,它仅安装whitenoise和django-storages,我该如何解决?

其他信息:

$ which python
/home/maks/.local/share/virtualenvs/personal-website-lhNGB4ub/bin/python

$ which pip
/home/maks/.local/share/virtualenvs/personal-website-lhNGB4ub/bin/pip

$ pyenv which python
/home/maks/.pyenv/versions/3.7.8/bin/python

在Windows上开发一段时间后,这个问题最近突然出现,发生时,我改用仅使用requirements.txt文件,但现在我想回到使用pipenv。

据我所知,这与文件的编码或行尾没有问题,而且我不确定何时/为什么确切地开始这种情况。

编辑: 运行pipenv install django可以正确安装django,但是pipfile和pipfile.lock保持相同,这意味着Pipfile没问题

3 个答案:

答案 0 :(得分:0)

setuptoolspipwheel是python软件包的一部分,已预先安装。只需将其更新为最新版本即可。

答案 1 :(得分:0)

我在这里看到的唯一模式是,whitenoise和django-storages不是顶级[packages]的一部分。也许,只是为了更接近问题的根源,请尝试拿一个包装,例如gunicorn,将其越过底部并执行以下操作:

`[packages.gunicorn]
 extras = [ "",]`

此外,PythonPATH在Windows上工作有点奇怪,请确保切换时不是问题。如果这些软件包出现在本地环境中而不是出现在您的env中,那么也许可以看看您的本机Python安装:)

答案 2 :(得分:0)

FIX: 因此,有效的方法是删除pipfile并使用pipenv install手动重新安装每个软件包,这导致pipfile看上去略有不同,从外观上看,引起我这个问题的是对pipenv本身的更新...看看:

旧的Pipfile:

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[requires]
python_version = "3.7"

[packages]
Django = "*"
django-split-settings = "*"
python-dotenv = "*"
django-compressor = "*"
django-libsass = "*"
Brotli = "*"
django-htmlmin = "*"
dj-database-url = "*"
wagtail = "*"
wagtail-metadata = "*"
wagtail-blocks = "*"
psycopg2 = "*"
django-tz-detect = "*"
wagtailcodeblock = "*"
django-taggit = "*"
django-taggit-templatetags2 = "*"
django-fontawesome-5 = "*"
django-debug-toolbar = "*"
wagtail-robots = "*"
wand = "*"
gunicorn = "*"

[dev-packages]
pylint = "*"
django-debug-toolbar = "*"

[packages.whitenoise]
extras = [ "brotli",]

[packages.django-storages]
extras = [ "dropbox",]

在全新的环境中手动重新安装每个软件包之后:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"
django-debug-toolbar = "*"

[packages]
django = "*"
django-split-settings = "*"
python-dotenv = "*"
django-compressor = "*"
django-libsass = "*"
brotli = "*"
django-htmlmin = "*"
dj-database-url = "*"
wagtail = "*"
wagtail-metadata = "*"
wagtail-blocks = "*"
django-tz-detect = "*"
wagtailcodeblock = "*"
django-taggit = "*"
django-taggit-templatetags2 = "*"
django-fontawesome-5 = "*"
django-debug-toolbar = "*"
wagtail-robots = "*"
wand = "*"
whitenoise = {extras = ["brotli"], version = "*"}
django-storages = {extras = ["dropbox"], version = "*"}
gunicorn = "*"

[requires]
python_version = "3.7"

使用pipenv install从此pipfile安装可以正常工作,并且所有软件包都已安装。

我不确定为什么这一切都会发生,也许这是pipenv中的错误,或者可能没有向后兼容性。如果有人知道,请告诉我。

如果要解决此问题而无需重新安装每个软件包,则只​​需替换如下所示的位即可:

[packages.whitenoise]
extras = [ "brotli",]

并将其转换为以下格式:

whitenoise = {extras = ["brotli"], version = "*"}

执行此操作后运行pipenv install,所有依赖项都将正确安装

我在Pipenv存储库上提交了一个问题:https://github.com/pypa/pipenv/issues/4433