Page 1 of 1

Pi 3 spidev (virtual environment)

Posted: Wed Nov 04, 2015 2:58 pm
by fopetesl
How can I install spidev for Python 3? Specifically into a virtual environment?

If I "pip install spidev" I get that it's already installed into Python 2.7 :(
I read I cannot uninstall Python 2.7 without probably breaking the Python system(s).

I don't have any spare hair to tear out, it's all gone !!

(search only reveals topics on Pi 2)

Re: Pi 3 spidev (virtual environment)

Posted: Wed Nov 04, 2015 3:31 pm
by fopetesl
Addedum:
I installed wiringpi2 also is installed to Python 2.7, so not accessible by Pi3 :(

Re: Pi 3 spidev (virtual environment)

Posted: Thu Nov 05, 2015 10:25 am
by ghans
What were the exact commands you tried ?

ghans

Re: Pi 3 spidev (virtual environment)

Posted: Thu Nov 05, 2015 1:39 pm
by fopetesl

Code: Select all

~$ sudo pip install spidev

~$ sudo apt-get update
~$ sudo apt-get install python-dev python-pip
~$ sudo pip install wiringpi2
~$ sudo python
import wiringpi2
wiringpi2.piBoardRev()
Works bot only in Python 2.7 NOT in Python 3

Re: Pi 3 spidev (virtual environment)

Posted: Thu Nov 05, 2015 8:37 pm
by DougieLawson
sudo apt-get install python3-pip
sudo apt-get install python3-spidev

sudo pip3 install spidev

Re: Pi 3 spidev (virtual environment)

Posted: Fri Nov 06, 2015 5:34 pm
by fopetesl
Nice one, Dougie!
Worked a treat.
Hope it helps someone else.
Thanks.

Re: Pi 3 spidev (virtual environment)

Posted: Wed Jun 07, 2017 12:17 pm
by kennethlbxx
Hi Dougie

I'm having a similar issue.
However in my case i'm not able to get spidev to be installed into the correct path(That is what i'm guessing).
Below is what I've done.
Hope you could give me some tips:)
Thank you!

(cv) pi@raspberrypi:~ $ sudo pip install spidev
Requirement already satisfied: spidev in /usr/local/lib/python2.7/dist-packages

(cv) pi@raspberrypi:~ $ pip freeze
appdirs==1.4.3
imutils==0.4.3
numpy==1.12.1
packaging==16.8
picamera==1.13
pyparsing==2.2.0
RPi.GPIO==0.6.3
six==1.10.0

i'm trying to run my codes which uses some opencv libraries which gave me the following error hence the question above.

(cv) pi@raspberrypi:~ $ python combined.py --conf conf.json
Traceback (most recent call last):
File "combined.py", line 18, in <module>
import spidev
ImportError: No module named spidev

Thanks again!

Regards Kenneth

Re: Pi 3 spidev (virtual environment)

Posted: Sat Jun 10, 2017 8:31 am
by DougieLawson
Try installing it with pip3