为什么pip冻结GENATE包_name=0.0.0

为什么pip冻结GENATE包_name=0.0.0,pip,Pip,我使用pipfreeze来提取我的virtualenv的每个依赖项,以便在其他地方使用这个环境,这样我就得到了requirements.txt,如下所示 certifi==2017.7.27.1 chardet==3.0.4 get==0.0.0 gevent==1.2.2 greenlet==0.4.12 idna==2.6 numpy==1.13.3 pandas==0.20.3 post==0.0.0 psycopg2==2.7.3.1 public==0.0.0 python-dateu

我使用pipfreeze来提取我的virtualenv的每个依赖项,以便在其他地方使用这个环境,这样我就得到了requirements.txt,如下所示

certifi==2017.7.27.1
chardet==3.0.4
get==0.0.0
gevent==1.2.2
greenlet==0.4.12
idna==2.6
numpy==1.13.3
pandas==0.20.3
post==0.0.0
psycopg2==2.7.3.1
public==0.0.0
python-dateutil==2.6.1
pytz==2017.2
query-string==0.0.0
request==0.0.0
requests==2.18.4
setupfiles==0.0.50
six==1.11.0
sqlalchemy==1.1.14
urllib3==1.22
我在其他计算机中使用了此要求,但每当我尝试运行pip install-r requirements.txt时,我都会遇到如下错误

$ pip install -r requirements.txt
Requirement already satisfied: certifi==2017.7.27.1 in d:\workspace\juice-project\venv\lib\site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: chardet==3.0.4 in d:\workspace\juice-project\venv\lib\site-packages (from -r requirements.txt (line 2))
Collecting get==0.0.0 (from -r requirements.txt (line 3))
  Using cached get-0.0.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "d:\workspace\juice-project\venv\lib\tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    PermissionError: [Errno 13] Permission denied: 'C:\\Users\\verys\\AppData\\Local\\Temp\\pip-build-1cd8yl0b\\get\\setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\verys\AppData\Local\Temp\pip-build-1cd8yl0b\get\
$pip安装-r requirements.txt
已满足要求:d:\workspace\juice project\venv\lib\site包中的certifi==2017.7.27.1(来自-r requirements.txt(第1行))
已满足要求:d:\workspace\juice project\venv\lib\site包中的chardet==3.0.4(来自-r requirements.txt(第2行))
收集get==0.0.0(来自-r requirements.txt(第3行))
使用缓存的get-0.0.0.tar.gz
从命令python setup.py egg_info完成输出:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“d:\workspace\juice project\venv\lib\tokenize.py”,第452行,打开
缓冲区=\u内置\u打开(文件名'rb')
权限错误:[Errno 13]权限被拒绝:“C:\\Users\\verys\\AppData\\Local\\Temp\\pip-build-1cd8yl0b\\get\\setup.py”
----------------------------------------
命令“python setup.py egg\u info”在C:\Users\verys\AppData\Local\Temp\pip-build-1cd8yl0b\get中失败,错误代码为1\

我认为这是由于窗口用户的特权造成的,所以我花了很多时间来解决这个问题。因为虫子,我很生气。你能解释一下为什么会产生这些未使用的东西以及为什么会出现这样的错误吗?

因为这些库-
get
request
(同一作者的库)-写得不正确。这不是你的问题,是他们的问题。你不能从你这边解决这个问题

看看他们的:

它不包含
version=…
kwarg。不幸的是,该库将始终是0.0.0版的版本,这是该
setupfiles
自制库的默认版本(请参阅)

PS:你真的想使用那种质量的库吗?为什么不把这个复制到你的代码中呢?这不是nodejs世界,在那里使用这样的nano模块是很好的


UPD:我刚刚注意到,
setup()
不是来自
setuptools
,而是来自,也是来自同一个作者,它被声明为猜测键的值。所以,也许它应该是有效的。但由于设置约定的这种非标准用法,它被破坏了

我不认为用这种方式替换
setuptools
是一种最佳做法,甚至不是一种好做法。而且这也不安全——恶意库作者只需注入任意代码即可在工作站/服务器上执行。尤其是


不过,在示例中,它需要一个
version=…
参数,而这些库中缺少该参数。

除了答案之外,还有一个问题:您是否真的安装了这些
get
/
请求
/
设置文件
?或者您是否尝试安装
请求
,但键入错误?然后考虑你的电脑潜在的黑客攻击和感染。我很难破译这些库,可能是作者为了隐藏恶意代码而故意这么做的。阅读这篇关于如何执行此类攻击的文章:@SergeyVasilyev我在最初的virtualenv中使用了请求,这一点没有问题。但我在我的公司里用代理运行这个环境。在删除以0.0.0结尾的每一行之后,我一直在使用此要求。这就是这里的区别:
请求
可以,而
请求
不行。前者是一个众所周知的库,后者可能是一个恶意软件包(因为它从内部看是多么神秘,并且在安装时通过
setup.py
执行了多少额外的bash逻辑)。仅输入一次错误就足以将后者及其依赖项输入到您的virtualenv中。
kwargs = dict()

# known-issues:
# pip running `python setup.py egg_info` before installation:
# 1) pip checks metadata name pip/req/req_install.py:run_egg_info()
# 2) pip attempts to discover all of the dependencies before installation
name = os.path.basename(os.getcwd()).split(".")[0].lower()

path = os.path.join(os.getcwd(), "requirements.txt")
if os.path.exists(path) and os.path.isfile(path):
    kwargs["install_requires"] = open(path).read().splitlines()

setup(name=name, **kwargs)