我在Mac上安装了Python。如果我运行python -V
,它将输出3.7.2
如果我运行以下命令:
virtualenv venv
source venv/bin/activate
python -V
我看到了3.7.2
。
如果我尝试运行nose
,则会出现此错误:
$ nosetests -s -v config_test.test_config:TestConfiguration
Failure: ModuleNotFoundError (No module named 'boto3') ... ERROR
======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'boto3')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 675, in _load
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/me/git/sdk-python-config/config_test/config_sdk.py", line 4, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (errors=1)
我立即关注3.6
引用。
如果我随后运行pip install boto3
,则在运行pip list
时可以看到该程序包,但是当我再次运行我的应用程序时,会遇到与上述相同的错误。
我尝试过pyenv global 3.7.2
和pyenv local 3.7.2
,但两者没有任何区别。
任何人都可以提出问题所在吗?
答案 0 :(得分:0)
nose
。用pip install nose
安装它后,我不得不停用venv并重新激活它。