How to solve the @file problem in requirements

When exporting the installation package in the virtual environment today, I D:\Anaconda\envs\虚拟环境名\Scriptsentered in the command line window under the directory of the virtual environment :

pip freeze > requirements.txt

Export the installation package of the virtual environment. After exporting, it is found that @file appears instead of the specific version number.
Insert picture description here
the reason:
This is a special syntax of pip installation package (supported since 19.1) PEP404 ,
but this kind of path depends on the environment, file:///URL is only available on the local file system, and you cannot add the generated requirements.txt The file is used on another computer.

Solution:
Use the following command to generate requirements.txt

pip list --format=freeze > requirements.txt

At this point, you can see that @file is no longer included.
Insert picture description here
Finally, you can use the following command to directly import the requirements.txt installation package into the new environment:

pip install -r requirements.txt

Guess you like

Origin blog.csdn.net/qq_38048756/article/details/115337465