我已经创建了一个虚拟环境:
Filtrations-MacBook-Pro:test filter$ virtualenv cbase
Using base prefix '/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/filter/Docs/tools/test/cbase/bin/python3.7
Also creating executable in /Users/filter/Docs/tools/test/cbase/bin/python
Installing setuptools, pip, wheel...
done.
好的,现在我将像这样激活它:
Filtrations-MacBook-Pro:test filter$ source cbase/bin/activate
(cbase) Filtrations-MacBook-Pro:test filter$
如您所见,我现在正在使用我的虚拟环境,因此当我运行which
时,它将指向我的vEnv:
(cbase) Filtrations-MacBook-Pro:test filter$ which python
/Users/filter/Docs/tools/test/cbase/bin/python
(cbase) Filtrations-MacBook-Pro:test filter$ which pip
/Users/filter/Docs/tools/test/cbase/bin/pip
(cbase) Filtrations-MacBook-Pro:test filter$
pip和python使用的版本:
(cbase) Filtrations-MacBook-Pro:test filter$ pip -V
pip 20.0.1 from /Users/filter/Docs/tools/test/cbase/lib/python3.7/site-packages/pip (python 3.7)
(cbase) Filtrations-MacBook-Pro:test filter$ python -V
Python 3.7.6
(cbase) Filtrations-MacBook-Pro:test filter$
现在我安装coinbase(https://pypi.org/project/coinbase/):
(cbase) Filtrations-MacBook-Pro:test filter$ pip install coinbase
Processing /Users/filter/Library/Caches/pip/wheels/9c/bd/d2/0deea345cde4f6a31d8165c0e83789bf2c836cfc1d7898300d/coinbase-2.1.0-py2.py3-none-any.whl
Collecting pycryptodome>=3.4.11
Using cached pycryptodome-3.9.4-cp37-cp37m-macosx_10_6_intel.whl (10.1 MB)
Collecting requests>=2.5
Using cached requests-2.22.0-py2.py3-none-any.whl (57 kB)
Collecting six>=1.9
Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2019.11.28-py2.py3-none-any.whl (156 kB)
Collecting idna<2.9,>=2.5
Using cached idna-2.8-py2.py3-none-any.whl (58 kB)
Collecting chardet<3.1.0,>=3.0.2
Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Using cached urllib3-1.25.8-py2.py3-none-any.whl (125 kB)
Installing collected packages: pycryptodome, certifi, idna, chardet, urllib3, requests, six, coinbase
Successfully installed certifi-2019.11.28 chardet-3.0.4 coinbase-2.1.0 idna-2.8 pycryptodome-3.9.4 requests-2.22.0 six-1.14.0 urllib3-1.25.8
(cbase) Filtrations-MacBook-Pro:test filter$ pip list
Package Version
------------ ----------
certifi 2019.11.28
chardet 3.0.4
coinbase 2.1.0
idna 2.8
pip 20.0.1
pycryptodome 3.9.4
requests 2.22.0
setuptools 45.1.0
six 1.14.0
urllib3 1.25.8
wheel 0.33.6
(cbase) Filtrations-MacBook-Pro:test filter$
好的,它似乎已经安装好了,但是当我尝试使用python运行它时:
(cbase) Filtrations-MacBook-Pro:test filter$ python -i
Python 3.7.6 (default, Dec 30 2019, 19:38:26)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from coinbase.wallet.client import Client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/filter/Docs/tools/test/coinbase.py", line 1, in <module>
from coinbase.wallet.client import Client
ModuleNotFoundError: No module named 'coinbase.wallet'; 'coinbase' is not a package
>>>
但是,如果我将我的site-packages文件夹放在其中,那就很荣耀了
(cbase) Filtrations-MacBook-Pro:test filter$ ls cbase/lib/python3.7/site-packages/
Crypto chardet-3.0.4.dist-info idna-2.8.dist-info requests six.py
__pycache__ coinbase pip requests-2.22.0.dist-info urllib3
certifi coinbase-2.1.0.dist-info pip-20.0.1.dist-info setuptools urllib3-1.25.8.dist-info
certifi-2019.11.28.dist-info easy_install.py pkg_resources setuptools-45.1.0.dist-info wheel
chardet idna pycryptodome-3.9.4.dist-info six-1.14.0.dist-info wheel-0.33.6.dist-info
type -a Python
返回以下内容:
(cbase) Filtrations-MacBook-Pro:test filter$ type -a python
python is /Users/filter/Docs/tools/test/cbase/bin/python
python is /usr/local/bin/python
python is /usr/bin/python
我不知所措,任何帮助将不胜感激。
答案 0 :(得分:1)
在测试文件夹中删除本地coinbase.py或在其他文件夹中运行python