I'm working on a project in python that uses OpenCV (2.3.1), among other libraries. So far, I just apt-get installed everything, but now I want to share my code with someone that might not have everything installed already. So, virtualenv seems like the perfect solution, but I get this.
$ python src/importcv.py # does nothing but import cv, no problems
$ virtualenv . # create virtualenv here
$ source bin/activate # activates this virtualenv
(p)$ python src/importcv.py
Traceback (most recent call last):
File "src/test.py", line 1, in <module>
import cv
ImportError: No module named cv
Was there something wrong in how I set up the virtualenv, or do I have to do some other step so it can see my opencv python bindings?
OpenCV can be installed using pip.
OpenCV makes adding computer vision to your Raspberry Pi projects a straight-forward process. Using it, you could train the Raspberry Pi to classify or recognise objects and react to them.
virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects.
Simply copy of the cv2*.so
file to the site-packages folder of the virtual environment. For example:
cp /usr/lib/python3.6/dist-packages/cv2.cpython-36m-aarch64-linux-gnu.so ~/your_virt_env_folder/YOUR_VIRT_ENV_NAME/lib/python3.6/site-packages/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With