doceme / py-spidev

MIT License
459 stars 205 forks source link

Virtual environment does not find spidev module [solved] #78

Open romybompart opened 5 years ago

romybompart commented 5 years ago

Hi people, I was working outside of my virtual environment initially. Then, I decided to move into a virtual env that I have already created, since I have to use OpenCv with some python3 dependencies already configured there. Then, when I ran the same .py that I was running before (outside of my env) I got a message:

 import spidev

ImportError: No module name 'spidev'

When I wrote: pip freeze, I noticed that my spi-dev module was not registered here.

-----Work around:

  1. I tried to install it again using>> sudo apt-get install sudo apt-get install python-dev mkdir python-spi cd python-spi wget https://raw.github.com/doceme/py-spidev/master/setup.py wget https://raw.github.com/doceme/py-spidev/master/spidev_module.c sudo python setup.py install
  2. I tried to run: sudo pip3 install spidev
  3. I tried to check if this has to do with the site-packages/ because in my virtual env I can see there is no spi-dev whereas outside of the virtual env the dist-package/ folder has spidev folder.

-----Solution Then: Yes, I just copied those spidev files/folders into my virtual env corresponding folder. Outside of my virtual env:

cd /usr/local/lib/python3.5/dist-packages sudo cp -r spidev* ~/.virtualenvs/cv/lib/python3.5/site-packages

I hope if you have experienced this issue and fix it in another way, please let me know. If you are having the same issue as I had and this worked for you please me know as well.