Pip 冻结创建一些奇怪的路径,而不是软件包版本

我正在开发一个 Python 包。我使用 pip freeze > requirements.txt将所需的包添加到 requment.txt 文件中。然而,我意识到一些包,而不是包的版本,有一些路径在他们之前。

numpy==1.19.0
packaging==20.4
pandas @ file:///opt/concourse/worker/volumes/live/38d1301c-8fa9-4d2f-662e-34dddf33b183/volume/pandas_1592841668171/work
pandocfilters==1.4.2

然而,在环境中,我得到的是:

>>> pandas.__version__
'1.0.5'

你知道怎么解决这个问题吗?

31719 次浏览

It looks like this is an open issue with pip freeze in version 20.1, the current workaround is to use:

pip list --format=freeze > requirements.txt

In a nutshell, this is caused by changing the behavior of pip freeze to include direct references for distributions installed from direct URL references.

You can read more about the issue on GitHub:

pip freeze does not show version for in-place installs

Output of "pip freeze" and "pip list --format=freeze" differ for packages installed via Direct URLs

Better freeze of distributions installed from direct URL references

Also, you can create txt file with another name and it won't include direct references then you can change the file name to requirements.txt

pip freeze > req.txt