-1

Here's what happens at first:

>>> import cv2
>>> print cv2.__version__
2.4.8

Then I activate a virtual enviconment

. venv/bin/activate

And try the same, but get:

>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2

How can this be? I was not aware that activating a virtual environment could make previously accessible modules inactive. Any suggestions?

Note: I'm using Kubuntu 14.04 at my university, where I have no admin rights.

Alex
  • 45
  • 6
  • 1
    But that's the whole point of a virtualenv: you only get the modules you installed within that environment. – Daniel Roseman Jul 19 '17 at 12:46
  • check `pip freeze` in active env to show available modules. – YuryChu Jul 19 '17 at 12:48
  • That makes sense. I thought it still inherits things that are installed globally. In that case - how can I make my venv make an exception for certain modules? – Alex Jul 19 '17 at 12:48
  • What did you think virtualenv is even for?! Just install cv2 inside your virtualenv. – wim Jul 19 '17 at 12:52

1 Answers1

0

Turns out the answer is very simple. By default virtual environments have no global site packages. Changing this once you already have your virtual environment can be done as described in the following:

Revert the `--no-site-packages` option with virtualenv

Alex
  • 45
  • 6