即使我安装了 Web3.py,也没有名为 "web3" 的模块(我使用的是 venv)
No module named "web3" even though I installed Web3.py (I am using a venv)
pip freeze output:
aiohttp==3.8.1
aiosignal==1.2.0
alembic==1.7.5
aniso8601==9.0.1
async-timeout==4.0.1
attrs==21.2.0
base58==2.1.1
bitarray==1.2.2
certifi==2021.10.8
charset-normalizer==2.0.7
click==8.0.3
cytoolz==0.11.2
eth-abi==2.1.1
eth-account==0.5.6
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
Flask==2.0.2
flask-marshmallow==0.14.0
Flask-Migrate==3.1.0
Flask-RESTful==0.3.9
Flask-Script==2.0.6
Flask-SQLAlchemy==2.5.1
frozenlist==1.2.0
hexbytes==0.2.2
idna==3.3
ipfshttpclient==0.8.0a2
itsdangerous==2.0.1
Jinja2==3.0.3
jsonschema==3.2.0
lru-dict==1.1.7
Mako==1.1.6
MarkupSafe==2.0.1
marshmallow==3.14.1
marshmallow-sqlalchemy==0.26.1
multiaddr==0.0.9
multidict==5.2.0
netaddr==0.8.0
parsimonious==0.8.1
protobuf==3.19.1
psycopg2==2.9.2
pycryptodome==3.11.0
pyrsistent==0.18.0
pytz==2021.3
requests==2.26.0
rlp==2.0.1
six==1.16.0
SQLAlchemy==1.4.27
toolz==0.11.2
typing_extensions==4.0.0
urllib3==1.26.7
varint==1.0.2
web3==5.25.0
websockets==9.1
Werkzeug==2.0.2
yarl==1.7.2
Python版本:3.10.0
我在我的 venv 中使用 pip install web3
命令安装了 Web3。
为了创建我的 venv,我做了 virtualenv -p python3 venv
,所以我认为虚拟环境没有问题。
但是在我的 test.py 中,当我执行以下操作时:
from web3 import Web3
我收到回溯错误,指出没有名为“web3”的模块
你在 运行 test.py 之前采购你的 venv 吗?
如果是这样,那就试试这个,
source venv/bin/activate
pip uninstall web3==5.25.0
pip install web3==5.25.0
python test.py
(因为你的 pip freeze 是正确的),也试试这个
which python
这应该会为您提供 python 当前正在被您的 shell 使用的垃圾桶。 (检查你得到的路径是不是venv)
pip freeze output:
aiohttp==3.8.1
aiosignal==1.2.0
alembic==1.7.5
aniso8601==9.0.1
async-timeout==4.0.1
attrs==21.2.0
base58==2.1.1
bitarray==1.2.2
certifi==2021.10.8
charset-normalizer==2.0.7
click==8.0.3
cytoolz==0.11.2
eth-abi==2.1.1
eth-account==0.5.6
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
Flask==2.0.2
flask-marshmallow==0.14.0
Flask-Migrate==3.1.0
Flask-RESTful==0.3.9
Flask-Script==2.0.6
Flask-SQLAlchemy==2.5.1
frozenlist==1.2.0
hexbytes==0.2.2
idna==3.3
ipfshttpclient==0.8.0a2
itsdangerous==2.0.1
Jinja2==3.0.3
jsonschema==3.2.0
lru-dict==1.1.7
Mako==1.1.6
MarkupSafe==2.0.1
marshmallow==3.14.1
marshmallow-sqlalchemy==0.26.1
multiaddr==0.0.9
multidict==5.2.0
netaddr==0.8.0
parsimonious==0.8.1
protobuf==3.19.1
psycopg2==2.9.2
pycryptodome==3.11.0
pyrsistent==0.18.0
pytz==2021.3
requests==2.26.0
rlp==2.0.1
six==1.16.0
SQLAlchemy==1.4.27
toolz==0.11.2
typing_extensions==4.0.0
urllib3==1.26.7
varint==1.0.2
web3==5.25.0
websockets==9.1
Werkzeug==2.0.2
yarl==1.7.2
Python版本:3.10.0
我在我的 venv 中使用 pip install web3
命令安装了 Web3。
为了创建我的 venv,我做了 virtualenv -p python3 venv
,所以我认为虚拟环境没有问题。
但是在我的 test.py 中,当我执行以下操作时:
from web3 import Web3
我收到回溯错误,指出没有名为“web3”的模块
你在 运行 test.py 之前采购你的 venv 吗?
如果是这样,那就试试这个,
source venv/bin/activate
pip uninstall web3==5.25.0
pip install web3==5.25.0
python test.py
(因为你的 pip freeze 是正确的),也试试这个
which python
这应该会为您提供 python 当前正在被您的 shell 使用的垃圾桶。 (检查你得到的路径是不是venv)