188

I am working on developing a python package. I use pip freeze > requirements.txt to add the required package into the requirement.txt file. However, I realized that some of the packages, instead of the package version, have some path in front of them.

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 

Whereas, inside the environment, I get:

>>> pandas.__version__ '1.0.5' 

Do you have any idea how to address this problem?

5
  • 1
    Not sure why this is happening, but it looks like pip freeze is outputting a direct reference for some reason. There is a discussion on Github about this issue: pip freeze does not show version for in-place installs Commented Jul 13, 2020 at 23:54
  • 18
    Does "pip list --format=freeze > requirements.txt" provide the expected results? Commented Jul 14, 2020 at 0:02
  • Yes. "pip list --format=freeze > requirements.txt" resolved the problem. Thanks. Commented Jul 14, 2020 at 0:33
  • Glad I could help you, if I did, consider upvoting / accepting my answer ;) Commented Jul 14, 2020 at 1:01
  • 1
    Done. I recently joined stackoverflow. Upvoting is not active yet :). Commented Jul 14, 2020 at 1:10

1 Answer 1

382

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

Sign up to request clarification or add additional context in comments.

5 Comments

2 years after your post and this is still relevant, thank you
3 years after your post and this is still relevant, thank you
The slight issue is that the output is different between the commands; pip freeze excludes pip and setuptools from frozen list but pip list --format=freeze includes them.
4 years after your post and this is still relevant, thank you
5 years after your post and this is still relevant, thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.