I am trying to use a module I have downloaded in Python 3, but when I call from i2clibraries import i2c_hmc5883l the error ImportError: No module named "i2clibraries" occurs.

The folderi2clibraries is housed in a file called q2wthat itself is housed in a directory called salt.

I added the lines

export QUICK2WIRE_API_HOME=~/salt/q2w

to the .bashrcso that I didn't have to type . ./setup.envevery time the Pi is rebooted to run the same lines that are in the .bashrc.

I'm new to both Raspian and Python 3, does anyone see a major error in the way I'm attempting to link these libraries? Is there a better way to add modules to Python 3? Is what I'm doing even linking?

  • I think you are creating a rod for your own back when you start installing "special" libraries. It might make a quick test easy but in the long run I would stick to using the "standard" Python smbus module (sudo apt-get install python3-smbus) and using one of the standard pieces of code to read your sensor. – joan Apr 22 '17 at 21:23
  • Hi Joan, having spent the last five hours with the smBus library I'd like to say that you were right. It's probably for the best I learned to use this library, even though it seems fairly high-level (in the way Python is higher than assembly). Thanks! – Patchwork Apr 23 '17 at 19:11
  • I think it will be worth it. I'm sure the majority of Python code you find for I2C sensors will be using the smbus module. – joan Apr 23 '17 at 19:17
  • Please refrain from putting meta information such as "solved" or "not relevant" in the title. If it really is not relevant it should be closed or deleted. Your update on the other hand suggests that there is a reasonable answer to the question and that might as well be posted as such. – Ghanima Apr 23 '17 at 19:22

The issue was never solved, but using the smBus python library ended up making the need for the quick2wire library irrelevant.

Per OP's edit to the question.


Try shifting the i2clibraries folder to your working directory. I.e : if your code is in desktop/myfolder , shift the library folder to "myfolder" . I know there is some other elegant ways of fixing this (adding paths) but this is the quickest and easiest fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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