python - 在 Linux EC2 实例中使用 sudo pip3 install python-binance 时 python-binance 无法编译错误
问题描述
更新 1:我正在 Linux AWS EC2 实例上安装 python-binance,当我尝试在 Python 3.7.0rc1 中使用 pip3 安装 python-binance 时出现以下错误。我使用了以下命令。
sudo pip3 install python-binance
在此部分以下输出之前,安装包一切正常。
Running setup.py install for pycparser ... done
Running setup.py install for regex ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-e8t4_b4g/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-0m6ommln-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib/python3.7/site-packages/setuptools/dist.py:355: UserWarning: Normalizing '2018.07.11' to '2018.7.11'
normalized_version,
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
copying regex_3/regex.py -> build/lib.linux-x86_64-3.7
copying regex_3/_regex_core.py -> build/lib.linux-x86_64-3.7
copying regex_3/test_regex.py -> build/lib.linux-x86_64-3.7
running build_ext
building '_regex' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/regex_3
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -fPIC -I/usr/include/python3.7m -c regex_3/_regex.c -o build/temp.linux-x86_64-3.7/regex_3/_regex.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-e8t4_b4g/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-0m6ommln-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-e8t4_b4g/regex/
我之前已经在 Mac 和 Windows 机器上成功安装了 python-binance,但不知道发生了什么。
然后我按照下面的评论安装了 gcc 并收到以下错误:
Requirement already satisfied: python-binance in /usr/lib/python2.7/site-packages/python_binance-0.7.0-py2.7.egg (0.7.0)
Collecting Twisted (from python-binance)
From cffi callback <function _verify_callback at 0x7f85b053e398>:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/twisted/
From cffi callback <function _verify_callback at 0x7f85ada43398>:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/twisted/
From cffi callback <function _verify_callback at 0x7f85bddc0c80>:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/twisted/
From cffi callback <function _verify_callback at 0x7f85bde6b7d0>:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/twisted/
From cffi callback <function _verify_callback at 0x7f85ada2c140>:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/twisted/
From cffi callback <function _verify_callback at 0x7f85ada2c2a8>:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Could not fetch URL https://pypi.org/simple/twisted/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/twisted/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)) - skipping
Could not find a version that satisfies the requirement Twisted (from python-binance) (from versions: )
No matching distribution found for Twisted (from python-binance)
解决方案
在有人指出我需要安装 gcc 之后,事情向前发展了,然后我发现我有 SSL 错误。我必须执行以下操作:
sudo pip3 uninstall pyopenssl
要删除和升级麻烦的包,然后:
sudo pip3 uninstall cryptography
之后,python-binance 安装成功。问题是它安装到 python 2.7 而不是 3.7。
推荐阅读
- google-maps - Google Maps Directions API - 在市内和市外行驶的距离
- java - 无限分配一个 SharedPreference ,但如何?
- java - 如何对自动散列的密码使用@Size 验证约束
- c++ - int[] 中的 foreach 没有显式声明
- ios - Swift 4.2 SafeAreaLayoutGuide 框架与 View Did Load 上的 view.frame 相同
- r - 在 R 闪亮的作品中阅读 excel 很慢
- html - HTML5:将 div 上加载的对象的语言更改为外部 html 文件
- java - 点在多边形中或不测试
- reactjs - 如何使用 React Redux 发出 post 请求?
- amazon-web-services - 如何将 AWS cloudwatch 日志流式传输到 ELK 堆栈?