1

I am still relatively new to Python, virtualenv and virtualenvwrapper but have hit a problem that I previously hacked a solution to but I am now looking for the right or the Pythonic way to solve it.

I would like to work with matplotlib so if I start a terminal session and type start a Python shell and type

from matplotlib import pyplot

I don't hit any problems as the screenshot shows:

enter image description here

However if I try the same command from within my virtualenv Python can not "see" the library, again here is the screenshot:

enter image description here

I believe that I need to add the library to my pythonpath but I have been going around in circles. In desperation I thought I could use pip to install the library when the virtualenv was active but that failed with errors (I can post the errors but didn't want to add unnecessary noise to my question)

Thanks in advance for any help you can provide.

Ian Carpenter
  • 8,346
  • 6
  • 50
  • 82

1 Answers1

2

Try to recreate environment with --system-site-packages option:

virtualenv --system-site-packages opencv

or (it seems that you are using virtualenvwrapper)

mkvirtualenv --system-site-packages opencv

--system-site-packages
Give the virtual environment access to the global site-packages.

ndpu
  • 22,225
  • 6
  • 54
  • 69
  • 1
    Perfect - thanks, two hours of faffing around not really understanding what I was doing but asked the question here and get the solution (that I understand!) within minutes. Thanks again. – Ian Carpenter Feb 17 '15 at 23:24