如何从另一个文件夹中获取Python软件包要求?
这是如此简单,不明白为什么它不起作用。
我的CMD在folder1
中打开。它的工作目录是folder1
。
folder1 --> folder2
我在folder2
中有一堆python
文件。我想获得其unignts.txt
文件,并将其存放在folder1
中。
同样,在我的CMD中打开folder1
,我运行pip冻结-path ./folder2> unignts.txt
它在folder1
中返回一个空unigess.txt
文件。如果我在folder2
中运行pip Freeze
,我会获得无问题的要求列表。
这似乎是如此的基础,但是为什么- 路径
无法按照我想要的方式工作?
This is so simple and don't understand why it isn't working.
I have my CMD opened in folder1
. Its working directory is folder1
.
folder1 --> folder2
I have a bunch of python
files in folder2
. I would like to obtain its requirements.txt
file and have it reside within folder1
.
Again, with my CMD opened in folder1
, I run pip freeze --path ./folder2 > requirements.txt
It returns an empty requirements.txt
file within folder1
. If I run pip freeze
within folder2
I obtain a list of requirements no problem.
This seems so basic, but why is --path
not working the way I want it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将项目文件夹与PIP安装的网站包装混合。这就是 - 路径参数所指的。由于您似乎不熟悉虚拟环境,因此您没有任何内容,并且您的2个项目文件夹正在使用完全相同的软件包,并且您获得了要求
。
You are mixing project folders with where pip installs it's site-packages. This is what the --path parameter refers to. Since you don't seem to be familiar with virtual environments, you don't have any and your 2 project folders are using exactly the same packages and you get the requirements.txt simply by
This is not different for your 2 project folders.
什么
pip Freeze
输出是安装东西的软件包列表。通常,它只是读取站点包
。路径
参数仅限于应该列出的包装,因此您要说将所有站点包装从文件夹1中获取,并将其限制在folder2 下,显然会返回空列表。您想做的是运行适当的pip-我想您在
folder2
下有一些 virtualenv ,因此它将是folder2/< venv>/bin/bin/bin/bin/bin/bin/ PIP冻结
。如果您没有,那么实际上是通过pip
降落到同一 site-packages 的所有事物,因此您将无法仅过滤文件。在folder2
中。What
pip freeze
outputs is the list of packages that he things are installed. Usually it just readssite-packages
. Thepath
parameter just restricts which packages it should listed, so you are saying take all site-packages from folder 1 and restrict them to this under folder2, which obviously returns empty list.What you want to do is run proper pip - I guess you have some virtualenv under
folder2
, so it would befolder2/<your venv>/bin/pip freeze
. If you havent, than actually all things you installed viapip
lands into the same, globalsite-packages
, so you won't be able to filter only this used by files infolder2
.我对此的解决方案是使用
pipReqs
与
cmd
在folder1
中打开a
unignts.txt
文件出现在folder1
中。这些软件包基于folder2
中的python
文件。My solution to this was to use
pipreqs
With
CMD
opened infolder1
, I ranpipreqs ./folder2 --savepath requirements.txt
A
requirements.txt
file appeared infolder1
. The packages were based on thepython
files infolder2
.