Search code examples
pythonpython-3.xvirtualenvpython-venv

venv doesn't appear to be getting used by Python


I have Python installed on the Mac. If I run python -V it outputs 3.7.2

If I run the following:

virtualenv venv
source venv/bin/activate
python -V

I see 3.7.2.

If I try to run nose I get this error:

$ 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)

I'm immediately concerned with the 3.6 references.

If I then run pip install boto3 I can see the package when I run pip list however I get the same error as above when I try running my applicaiton again.

I've tried pyenv global 3.7.2 and pyenv local 3.7.2 but neither makes any difference.

Can anybody suggest what the problem might be?


Solution

  • nose wasn't installed in the venv. After I installed it with pip install nose I had to deactivate the venv and reactivate it.