0
pip freeze > requirements.txt

I use this command to generate some requirements, but the result with some the local file location. How to avoid them?

absl-py @ file:///home/conda/feedstock_root/build_artifacts/absl-py_1637088766493/work
aiohttp @ file:///D:/bld/aiohttp_1637087223487/work
aiosignal @ file:///home/conda/feedstock_root/build_artifacts/aiosignal_1636093929600/work
albumentations==1.1.0
async-timeout @ file:///home/conda/feedstock_root/build_artifacts/async-timeout_1637092647930/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1620387926260/work
autopep8==1.6.0
backcall==0.2.0

The "@file:///home/conda/feedstock_root/build_artifacts/attrs_1620387926260/work" thing I don not want.

PinkR1ver
  • 402
  • 1
  • 4
  • 13

2 Answers2

4

I would try the following instead:

pip list --format=freeze > requirements.txt
1

EDIT: This approach should not be used as answer, but it may be useful in case of more sophisticated processing.

Why don't try to code this kind of filtering?

Take a look at the code below:

import subprocess

output = subprocess.check_output(['pip', 'freeze']).decode().split('\r\n')
result = list(filter(lambda x: False if '@' in x else True, output))
print(result)
fname = 'requirements_test.txt'
with open(fname, mode='w', encoding='utf8') as f:
    for row in result:
        f.write(row + '\n')
aestet
  • 314
  • 1
  • 3
  • 13