我正在尝试在python上安装SSL的安全修复程序:
# pip -v install pyopenssl ndg-httpsclient pyasn1 --timeout 10 --default-timeout=10
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): ndg-httpsclient in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /usr/local/lib/python2.7/dist-packages (from pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/lib/python2.7/dist-packages (from pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /usr/local/lib/python2.7/dist-packages (from cryptography>=0.7->pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/dist-packages (from cryptography>=0.7->pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /usr/local/lib/python2.7/dist-packages (from cryptography>=0.7->pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /usr/local/lib/python2.7/dist-packages (from cryptography>=0.7->pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.1.0 in /usr/local/lib/python2.7/dist-packages (from cryptography>=0.7->pyopenssl)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python2.7/dist-packages (from cffi>=1.1.0->cryptography>=0.7->pyopenssl)
Cleaning up...
Starting new HTTPS connection (1): pypi.python.org
"GET /pypi/pip/json HTTP/1.1" 200 50976
如果我打断:
/pypi/pip/jsonTraceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.1.2', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 248, in main
pip_version_check(session)
File "/usr/local/lib/python2.7/dist-packages/pip/utils/outdated.py", line 126, in pip_version_check
headers={"Accept": "application/json"},
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 605, in send
r.content
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 307, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 243, in read
data = self._fp.read(amt)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 54, in read
self.__callback(self.__buf.getvalue())
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/controller.py", line 244, in cache_response
self.serializer.dumps(request, response, body=body),
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 276, in set
return super(SafeFileCache, self).set(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/caches/file_cache.py", line 99, in set
with self.lock_class(name) as lock:
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/lockfile/__init__.py", line 238, in __enter__
self.acquire()
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/lockfile/mkdirlockfile.py", line 56, in acquire
time.sleep(wait)
KeyboardInterrupt
有什么建议吗?我在一些搜索后尝试了超时和默认超时,但我认为它们完全被忽略了。
代码上的我看到了:
def acquire(self, timeout=None):
timeout = timeout is not None and timeout or self.timeout
end_time = time.time()
if timeout is not None and timeout > 0:
end_time += timeout
if timeout is None:
wait = 0.1
else:
wait = max(0, timeout / 10)
while True:
try:
os.mkdir(self.lock_file)
except OSError:
err = sys.exc_info()[1]
if err.errno == errno.EEXIST:
# Already locked.
if os.path.exists(self.unique_name):
# Already locked by me.
return
if timeout is not None and time.time() > end_time:
if timeout > 0:
raise LockTimeout("Timeout waiting to acquire"
" lock for %s" %
self.path)
else:
# Someone else has the lock.
raise AlreadyLocked("%s is already locked" %
self.path)
**time.sleep(wait)**
else:
# Couldn't create the lock for some other reason
raise LockFailed("failed to create %s" % self.lock_file)
else:
open(self.unique_name, "wb").close()
return
如何解决此问题?有人有想法吗?
答案 0 :(得分:0)
您可以检查显示的日志中是否存在以下异常: 回溯(最近一次调用最后一次):
文件 “C:\ python34 \ LIB \站点包\ pip_vendor \锁文件\ mkdirlockfile.py” 第40行,收购 os.mkdir(self.lock_file)FileExistsError:[WinError 183]当该文件已存在时无法创建文件: “C:\用户\\应用程序数据\本地\ PIP \缓存\ HTTP \˚F。\ E \ d \ 0 。\ E \ fed0ed508030b766d5b0c2792132c8bf197804464765b46b361f93a4.lock'
如果您可以尝试删除pip目录并再试一次