[SOLVED] How to install BrickPi3 in a virtualenv in python

I was trying to install the brickpi3 python module in a python virtual environment. I created the the environment with virtualenv env --python=python3 I then ran the install.sh script and even tried running the setup.py script. It does not import. Yes I ran this all with the environment activated and also rebooted.

Anyone have any ideas?

Hi @graykevinb,

I was able to import brickpi3 module with Python 2 and Python 3 within a virtualenv environment.


Here’s what I’ve been doing:

  1. I cd-ed to ~/Desktop where the user has rw permissions.

  2. Created a virtual environment with the virtualenv env --python=python3 command.

  3. Activated the env environment with source env/bin/activate.

  4. Created another folder on the Desktop called env-test, where than I cd-ed to it.

  5. git clone https://github.com/DexterInd/BrickPi3.git - we need the user to have rw access to it, otherwise, pip freeze won’t show up our package.

  6. cd-ed to ~/Desktop/env-test/BrickPi3/Software/Python.

  7. Run the following commands in this order:

  • python setup.py clean - removes the old build (if there’s one)

  • python setup.py build - creates a new build

  • python setup.py install - installs the current build

  1. Install spidev package with pip install spidev.

  2. Type python and try to import the brickpi3 module - it’s going to work.


If there are any other questions, Kevin, please tell us here.

Thank you!

1 Like

It worked! Big thanks! I did things a bit differently. I used python3 and did it in the home folder.

Hi @graykevinb,

I’m glad it worked for you.
I’m now closing the thread.

Thank you!