尝试从pip安装web3时出现以下问题:
$ sudo pip install web3
The directory '/home/chris/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/chris/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting web3
Downloading https://files.pythonhosted.org/packages/96/76/6313b5d55edb5ac6fdbde9beacafefb04fccd692348ed2085856c95dda25/web3-4.1.0.tar.gz (85kB)
100% |████████████████████████████████| 92kB 1.4MB/s
Collecting cytoolz<1.0.0,>=0.9.0 (from web3)
Downloading https://files.pythonhosted.org/packages/36/f4/9728ba01ccb2f55df9a5af029b48ba0aaca1081bbd7823ea2ee223ba7a42/cytoolz-0.9.0.1.tar.gz (443kB)
100% |████████████████████████████████| 450kB 3.6MB/s
Collecting eth-abi<2,>=1.0.0 (from web3)
Downloading https://files.pythonhosted.org/packages/8d/f1/212b138e8e2e46788054b456a068ae060f07464fd03f5f7ec0eb749c35d0/eth-abi-1.0.0.tar.gz
Collecting eth-account==0.1.0-alpha.2 (from web3)
Downloading https://files.pythonhosted.org/packages/57/8e/12a906f171f2860c0baf0f07bde4d7b390a3eacb29adc8341c7bbec356f6/eth-account-0.1.0a2.tar.gz
Collecting eth-utils<2.0.0,>=1.0.1 (from web3)
Downloading https://files.pythonhosted.org/packages/6f/08/0787c6ccb1b8dca4a15c12f67ed3d383f9f361eeb1836d6fe698caf46bca/eth-utils-1.0.3.tar.gz
Collecting hexbytes<1.0.0,>=0.1.0 (from web3)
Downloading https://files.pythonhosted.org/packages/81/15/fcd3a5ad583673ce52f0aac8e1246b91e7c88acbeae47863c30bfb264436/hexbytes-0.1.0.tar.gz
Complete output from command python setup.py egg_info:
zip_safe flag not set; analyzing archive contents...
pypandoc.__init__: module references __file__
Installed /tmp/pip-install-KPGcEs/hexbytes/.eggs/pypandoc-1.4-py2.7.egg
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-KPGcEs/hexbytes/setup.py", line 67, in <module>
'Programming Language :: Python :: Implementation :: PyPy',
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 372, in __init__
_Distribution.__init__(self, attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 528, in finalize_options
ep.load()(self, ep.name, value)
File "/tmp/pip-install-KPGcEs/hexbytes/.eggs/setuptools_markdown-0.2-py2.7.egg/setuptools_markdown.py", line 22, in long_description_markdown_filename
output = pypandoc.convert(markdown_filename, 'rst')
File "/tmp/pip-install-KPGcEs/hexbytes/.eggs/pypandoc-1.4-py2.7.egg/pypandoc/__init__.py", line 66, in convert
raise RuntimeError("Format missing, but need one (identified source as text as no "
RuntimeError: Format missing, but need one (identified source as text as no file with that name was found).
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-KPGcEs/hexbytes/
所以每当我尝试.py脚本时,我都会收到以下错误:
from web3 import Web3, KeepAliveRPCProvider, IPCProvider
ImportError: cannot import name Web3
知道可能导致这种情况的原因,或者如何解决这个问题?
答案 0 :(得分:0)
我能够通过将web3==4.1.0
移到requirements.txt
文件并运行pip install -r requirements.txt
来解决该问题。
不知道为什么会奏效。但是,尝试从setup.py
文件安装它仍然失败。
顺便说一句,根据web3
README,他们只支持python 3.5 +。