我正在运行Linux服务器(Linux 4.1.12-124.19.1.el7uek.x86_64#2 SMP Wed Sep 5 sep 5 Sep 5 13:41:16 PDT 2018 x86_64 x86_64 x86_64 x864 x86_64 x86_64 gnu/linux gnu/linux)at python 2.7.5(dbas)对于他们的脚本为2.7.5),并试图使PIP和请求运行。
我遇到了一个问题,因为当我尝试安装 epel-release
时,它会告诉我“无包”。因此,我必须做
"yum install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
,最终让我要做的
"yum install python-pip"
是安装PIP。
然后,我确实
"python -m pip install requests"
要安装请求。
看起来不错,但是当我运行DBA给我检查的测试脚本时,它会给我这一点。
"Traceback (most recent call last):
File "/mnt/EBS_Cloning_Repo/clone/scripts/test.py", line 2, in <module>
import requests
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 133, in <module>
from . import utils
File "/usr/lib/python2.7/site-packages/requests/utils.py", line 27, in <module>
from . import certs
File "/usr/lib/python2.7/site-packages/requests/certs.py", line 15, in <module>
from certifi import where
File "/usr/lib/python2.7/site-packages/certifi/__init__.py", line 1, in <module>
from .core import contents, where
File "/usr/lib/python2.7/site-packages/certifi/core.py", line 17
def where() -> str:
^
SyntaxError: invalid syntax"
我确实发现这可能是由于仅运行python命令而不是像python2一样引起的,因此我尝试用python2命令重做一些命令,结果相同。
我确实有另一台服务器,随着它应该运行,我比较了它指向的文件,并在其中看到了一些丢失的信息(diff输出一个请求),但是我不确定我可以用这些信息做什么。
I am running a Linux server (Linux 4.1.12-124.19.1.el7uek.x86_64 #2 SMP Wed Sep 5 13:41:16 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux) with python 2.7.5 on it (DBAs want it to be 2.7.5 for their script) and trying to get pip and requests running.
I was having a problem getting pip on, because when I would try to install the epel-release
, it would tell me "no package" named that. So I had to do
"yum install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
Which finally let me do
"yum install python-pip"
to get pip installed.
I then did
"python -m pip install requests"
to install requests.
It looked good, but when I run the test script that the DBAs gave me to check, it gives me this.
"Traceback (most recent call last):
File "/mnt/EBS_Cloning_Repo/clone/scripts/test.py", line 2, in <module>
import requests
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 133, in <module>
from . import utils
File "/usr/lib/python2.7/site-packages/requests/utils.py", line 27, in <module>
from . import certs
File "/usr/lib/python2.7/site-packages/requests/certs.py", line 15, in <module>
from certifi import where
File "/usr/lib/python2.7/site-packages/certifi/__init__.py", line 1, in <module>
from .core import contents, where
File "/usr/lib/python2.7/site-packages/certifi/core.py", line 17
def where() -> str:
^
SyntaxError: invalid syntax"
I did find that this could be caused by running just the python command, instead of one like python2, so I try redoing some of the commands with the python2 command with the same results.
I do have another server, running as it should with this, and I compared the files that it is pointing to, and seeing some missing information in them (diff output one request), but I am not sure what I can do with that information.
发布评论
评论(2)
TLDR
分析
它使用Python 2.7
/usr/lib/
python2.7
/site-cake
in Error li>; str in
def whese() - &gt; str
是一种类型注释python 3.0 引入了a 函数注释语法 in pep 3107
pep 484 https://docs.python.org/3/library/typing.html#module-typing“ rel =” nofollow noreferrer“>
键入
modulepython 2.7如果找到注释,肯定会提高无效的语法
test.py:
输出:
认证被隐式地作为亚依赖性/子包
我们可以使用PIP的解析器在安装示例示例
:
命令:
输出:输出:
TLDR
Analysis
It's using python 2.7
/usr/lib/
python2.7
/site-packages
in errorThe
-> str
indef where() -> str
is a type annotationPython 3.0 introduced a function annotation syntax in PEP 3107
Python 3.5 officially adds standard definitions for them via PEP 484's
typing
modulePython 2.7 would definitely raise invalid syntax if it found an annotation
test.py:
Output:
certifi
certifi is being implicitly fetched as a sub-dependency / sub-package
Example
Optional sandbox:
Command:
Output:
我认为这是一个兼容性错误。 PIP损坏,我尝试了
YUM删除Python2-PIP
并重新安装它。我认为经过错误认证的依赖性使它不利。因此,您可以复制将良好的认证依赖性文件与已发行的PC复制。位置为/usr/lib/python2.7/site-packages/
。I think this is a compatibility bug. The pip is broken, I tried
yum remove python2-pip
and reinstalling it. I think the error-certified dependency makes it bad. So you can COPY the good certified dependency files to the destinated PC. The location is/usr/lib/python2.7/site-packages/
.