How to setup python-smbus in the virtual env? Pip does not find any appropriate package. Is there a way to make main python installation's libraries visible to virtual env?


2 Answers 2


The various releases are listed here the Debian Wheezy python-smbus page.

I assume you can just install via apt-get, although I believe you need to i2c tools package as well:

sudo apt-get install i2c-tools
sudo apt-get install python-smbus

When you create your virtual environment you should be able to inherit the system site packages using the --system-site-packages flag for example:

virtualenv --system-site-packages my_env

You can read more at the virtualenv.org website.

Incase I misunderstood your question...

If you are asking how to install into your virtual environment from a package server that is pip compatible and contains the package (python-smbus) you can update your pip.conf file to include it.

Navigate to the .pip directory under your users root folder. Then edit the pip.conf file, for example:

vim /home/pi/.pip/pip.conf

You can then add an additional package repository in here:

index-url = path/to/package/server 

Installing it in your virtual environment is then as easy as:

./bin/pip install <package>
  • 1
    Thank you, I'd first opt for inheriting system packages. Wonder if I could modify existing virtual environment to inherit them, but I will try it out.
    – user9243
    Aug 28, 2013 at 10:44
  • There is no /.pip/ in /home/pi/. What now?
    – Bort
    Dec 4, 2016 at 14:14
  • One reason for setting up a virtualenv, is to have an isolated environment owned by an isolated user who comes to your (web) appllication from outside. That user is typically not a sudoer. So sudo apt-get install won't work. Better answers for that use case here and here.
    – RolfBly
    Dec 27, 2016 at 20:38

Try using smbus2 instead. It is a pure python replacement you can just install with pip as normal. Works fine for me. https://pypi.org/project/smbus2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.