dianep
Posts: 1
Joined: Wed Dec 05, 2018 6:47 pm

Problem importing modules

Wed Dec 05, 2018 6:56 pm

Hi. I have a brand new raspberry pi which I set up yesterday, installing Raspbian via Noobs. I also installed some libraries for sensors that I want to use.

I wired up the first sensor (BME280 ) and ran the example code that was provided. It works fine, showing the data read via the sensor. Now, I want to edit the file but the library is write protected; I get the message "permission error, file not writeable". If I try to save the file to another folder (just the home>pi folder), the script fails with an import error - ImportError:no module found named Adafruit_BME280 . At this stage, I haven't changed the code that ran fine previously, just moved it to a different folder.

As a newbie, I feel that I am missing something obvious. Help would be much appreciated.

User avatar
Paeryn
Posts: 2472
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Problem importing modules

Thu Dec 06, 2018 1:51 am

dianep wrote:
Wed Dec 05, 2018 6:56 pm
Hi. I have a brand new raspberry pi which I set up yesterday, installing Raspbian via Noobs. I also installed some libraries for sensors that I want to use.

I wired up the first sensor (BME280 ) and ran the example code that was provided. It works fine, showing the data read via the sensor. Now, I want to edit the file but the library is write protected; I get the message "permission error, file not writeable". If I try to save the file to another folder (just the home>pi folder), the script fails with an import error - ImportError:no module found named Adafruit_BME280 . At this stage, I haven't changed the code that ran fine previously, just moved it to a different folder.

As a newbie, I feel that I am missing something obvious. Help would be much appreciated.
What libraries did you install and how did you install them? Where was the example code that you ran?

If trying to run your copy of the example program doesn't work but the original did then, if everything else is the same (you run the example program in the same way), it sounds like the Adafruit_BME280 module may be local to where the example program was (i.e. in the same directory) rather than globally available. If so then you probably just need to copy it over to the same place where you copied the program (it will be either a directory called Adafruit_BME280 or a file called Adafruit_BME280.py), there may be other local modules too.
She who travels light — forgot something.

Return to “Python”