升级点子后,我尝试进行“点子冻结”,但是我遇到了这个错误:
# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 737kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-10.0.1
# pip freeze
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
在这里阅读一些帖子,我发现了各种解决方案,但是它不起作用。 因此,我尝试了另一件事,例如使用easy_install进行安装:
# sudo python -m easy_install --upgrade pyOpenSSL
Searching for pyOpenSSL
Reading https://pypi.python.org/simple/pyOpenSSL/
Best match: pyOpenSSL 18.0.0
Downloading https://files.pythonhosted.org/packages/9b/7c/ee600b2a9304d260d96044ab5c5e57aa489755b92bbeb4c0803f9504f480/pyOpenSSL-18.0.0.tar.gz#sha256=6488f1423b00f73b7ad5167885312bb0ce410d3312eb212393795b53c8caa580
Processing pyOpenSSL-18.0.0.tar.gz
Writing /tmp/easy_install-_qJ8_t/pyOpenSSL-18.0.0/setup.cfg
Running pyOpenSSL-18.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_qJ8_t/pyOpenSSL-18.0.0/egg-dist-tmp-KM4cDC
warning: no previously-included files found matching 'leakcheck'
warning: no previously-included files found matching 'codecov.yml'
warning: no previously-included files matching '*.py' found under directory 'leakcheck'
warning: no previously-included files matching '*.pem' found under directory 'leakcheck'
warning: no previously-included files matching '*.cert' found under directory 'examples/simple'
warning: no previously-included files matching '*.pkey' found under directory 'examples/simple'
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching '.travis'
no previously-included directories found matching '.mention-bot'
zip_safe flag not set; analyzing archive contents...
Adding pyOpenSSL 18.0.0 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/pyOpenSSL-18.0.0-py2.7.egg
Processing dependencies for pyOpenSSL
Searching for cryptography>=2.2.1
Reading https://pypi.python.org/simple/cryptography/
Best match: cryptography 2.2.2
Downloading https://files.pythonhosted.org/packages/ec/b2/faa78c1ab928d2b2c634c8b41ff1181f0abdd9adf9193211bd606ffa57e2/cryptography-2.2.2.tar.gz#sha256=9fc295bf69130a342e7a19a39d7bbeb15c0bcaabc7382ec33ef3b2b7d18d2f63
Processing cryptography-2.2.2.tar.gz
Writing /tmp/easy_install-rHRU6X/cryptography-2.2.2/setup.cfg
Running cryptography-2.2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-rHRU6X/cryptography-2.2.2/egg-dist-tmp-eABQpn
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/dist-packages/easy_install.py", line 5, in <module>
main()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2199, in main
lambda: setup(
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2185, in with_ei_usage
return f()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2202, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 668, in install_item
self.process_distribution(spec, dist, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 716, in process_distribution
[requirement], self.local_index, self.easy_install
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 631, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 874, in best_match
return self.obtain(req, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 886, in obtain
return installer(requirement)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 666, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 856, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1078, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1063, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 68, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 114, in run
return func()
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 67, in runner
_execfile(setup_script, ns)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 43, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-rHRU6X/cryptography-2.2.2/setup.py", line 28, in <module>
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
,因此,升级了“ setuptools”:
# sudo python -m easy_install --upgrade setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Best match: setuptools 39.2.0
Downloading https://files.pythonhosted.org/packages/1a/04/d6f1159feaccdfc508517dba1929eb93a2854de729fa68da9d5c6b48fa00/setuptools-39.2.0.zip#sha256=f7cddbb5f5c640311eb00eab6e849f7701fa70bf6a183fc8a2c33dd1d1672fb2
Processing setuptools-39.2.0.zip
Writing /tmp/easy_install-wH5_qA/setuptools-39.2.0/setup.cfg
Running setuptools-39.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-wH5_qA/setuptools-39.2.0/egg-dist-tmp-cpMLIT
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/dist-packages/easy_install.py", line 5, in <module>
main()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2199, in main
lambda: setup(
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2185, in with_ei_usage
return f()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2202, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 666, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 856, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1078, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1063, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 68, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 114, in run
return func()
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 67, in runner
_execfile(setup_script, ns)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 43, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-wH5_qA/setuptools-39.2.0/setup.py", line 195, in <module>
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 266, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 301, in finalize_options
ep.load()(self, ep.name, value)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2195, in load
raise ImportError("%r has no %r attribute" % (entry, attr))
ImportError: <module 'setuptools.dist' from '/usr/lib/python2.7/dist-packages/setuptools/dist.pyc'> has no 'check_specifier' attribute
最后一次尝试,使用特定版本的pyOpenSSL:
# sudo pip install pyOpenSSL==16.2.0
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
请解决这个问题的另一个想法? :) 非常感谢。 F。
答案 0 :(得分:8)
问题来自pyopenssl
。您可以做的第一件事就是尝试删除并重新安装pyopenssl
:
apt-get --auto-remove --yes remove python-openssl
pip install pyOpenSSL
但这也可能是路径问题。
答案 1 :(得分:1)
升级操作系统提供的pip
是众所周知的“自己的目标”,除非绝对必要,否则应避免。
首先,您可能需要重新安装OS软件包,以恢复对'pip'命令的正常使用。
如果必须使用较新的pip
:请尝试通过自包含的安装程序进行安装,请参见此处:https://pip.pypa.io/en/stable/installing/
,而不要使用现有的pip
。除非您必须让所有用户都可以使用它,否则请使用'--user'选项运行安装-并在使用pip
安装软件包时使用相同的选项-这样,您就不必理会操作系统提供的Python和pip东西了,不要覆盖它们,并且可以随时从~/.local/
中删除所有与Python相关的内容来返回它们。
在所有情况下,从pip
恢复为目前的状态后,请尝试首先升级pyOpenSSL(或使用pip install
--user
对其进行升级)。
我在网上找到的另一个有用的提示:始终使用python -m pip
而不是直接运行pip
,这样可以避免pip
选择错误版本或pip模块的问题(或运行错误的python
可执行文件(如果有多个)。