Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Install ABElectronics_Python_Libraries in Virtual Environment - not working - IOPi Blink LED

2423 Views - Created 30/03/2018

30/03/2018

Posted by:
kyPi2017

kyPi2017 Avatar

Hi,

I'm trying to Install ABElectronics_Python_Libraries in Virtual Environment - its not working for me.

i do this:
1. download the Lib into /home/pi/Downloads/ABElectronics_Python_Libraries
2. cd into the downloaded folder and install : sudo python3 setup.py install

in this stage i'm doing small test, following the blinking led and test -- it works fine - led is blinking...
https://www.abelectronics.co.uk/kb/article/17/io-pi-tutorial-1---the-blinking-led

3. now that python3 has the lib installed, im creating virtual environment :
$ sudo python3 –m venv MyEnv1
from my understanding, once the ABElectronics_Python_Libraries already installed in the MAIN python
the virtual environemnt MyEnv1 should have the ABElectronics included.

so, i;m activating the virtual environemnt, and runing the blinking led program, and i get erro rthat the IOPi package not exists .
(MyEnv1) pi@raspberrypi:~/src/python/Projects/BlinkLED $ python app.py
Traceback (most recent call last):
File "app.py", line 1, in <module>
from IOPi import IOPi
ImportError: No module named 'IOPi'

What is wrong here ?

Please advise

Thanks,



















https://www.abelectronics.co.uk/kb/article/23/python-library-and-demos

30/03/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi

You may need to run the setup.py within the virtual environment in order to run the demo script. Alternatively you can copy the IOPi.py file from the IOPi folder into the same folder as the script you are trying to run and it should then work without having to install the library in the virtual environment.

31/03/2018

Posted by:
kyPi2017

kyPi2017 Avatar

Hi Andrew,

I already try this "You may need to run the setup.py within the virtual environmen"
before writing my post - but i'll try again.

you also write "Alternativly you can copy the IOPi.py file from the IOPi folder into the same folder as the script you are tring to run"
Do you think that this will be a better choice than running the setup.py after activating the virtual environment ?
What about updating new versions of the ABElectronics_Python_Libraries when new one released ?

Thank you !

31/03/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Copying the IOPi.py file into the same folder as your project does have the advantage that it makes it portable so you can move your project to another Raspberry Pi without having to install the ABElectronics_Python_Libraries on that machine.

If a new version of the ABElectronics_Python_Libraries is released you can just overwrite the old IOPi.py with the updated one and it should continue working.

01/04/2018

Posted by:
kyPi2017

kyPi2017 Avatar

Hi andrew,

Thanks for the update.
I want to go with this option of copying the whole ABElectronics_Python_Libraries library into my project root
and change the code to:
from ABElectronics.IOPi import IOPi
then i can move the entire project to another pi and it will be easier to maintain versions etc..

Thnaks !

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.