Piicodev not found on PyPi

Hi,
This is my first post and I am totally new to all this so please be patient.
I have just ordered some Piicodev gear and before it arrives I am trying to prepare a spare Pi 4B. I have installed a fresh Rasp Pi OS.
When I try to install Piicodev with the Thonny package manager it cannot find it. There is no result at all.
I have seached for help but suggestions about manually installing it result in a long error message about this being an externally managed package etc etc.
So now I have no idea how to proceed.
Any help greatly appreciated.
Ian

1 Like

Hey @Ian100768, Welcome to the forums!

Sorry to hear you are having trouble with this. The “Virtual environment” message is one we are very familiar with at this point. A change to the Raspberry Pis software now requires Python code to be run inside of a separate virtual environment on the Pi to stop unexpected conflicts between the Python the system uses to boot and run as expected and the user’s Python projects.

We have a tutorial for how to setup and use a virtual environment at the following link. This is a great skill to have under your belt as this is probably going to be a required step for programming with Python on the Pi going forward.

The install commands for this library should work as expected once you have set up this virtual environment.

Let us know if you need any more help!

To summarise the information in the above tutorial, you should be able to create a virtual enviroment and install Piicodev inside of it with the following commands.

python3 -m venv --system-site-packages piicodev
source piicodev/bin/activate
pip3 install piicodev

The tutorial is still worth a read to explain why this works but the shortcut is there if you need!

Thank you so much for the rapid responses!
I went with your summary Samuel and it worked.
So I now have a venv called piicodev.
I think I had already created a venv called myenv by following instructions elsewhere.
Does this matter and how can I remove it?
Ian

1 Like

Hey Ian,

Having two virtual enviroments shouldn’t matter but keep in mind that any libraries you install will be specific to the virtual environment you had activated when you ran the install command.

This means it is likely that the older environment myenv will not contain the piicodev library. You should be fine to leave this but if you want to clean up your Pi you should be able to delete the ‘myenv’ folder from your device.

You can do this by using the file manager to delete the folder called ‘myenv’.

Hopefully, it’s smooth sailing from here! Let us know if you need a hand with anything else :slight_smile:

sorry for my level of ignorance!
I have deleted the myenv folder.
Now when I open Thonny it obviously can’t find it and wants me to select another.
How do I now select the piicodev venv?
Hopefully I will then be OK!

Hey @Ian100768,

No worries at all! We all have to start somewhere with all this :slight_smile:

The guide linked above has some helpful photos of how to tell thonny which virtual environment to use if my description is a little confusing.

From the top menu navigate through Run > Configure Interpreter then hit the 3 dots (...) next to the ‘Python Executable’ section. This will open a file manager window which you can use to navigate to and select the correct virtual environment.

After you reload Thonny you should be good to go!

All looks good now.
Thanks again. If this is typical of the support here I am very impressed!
Ian

2 Likes

Good to hear you got it sorted out!

Best of luck with your project. We will do our best to help out if you get stuck again :slight_smile:

1 Like