Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError
#1
Hi, I am writing a program and when I try to run it I get an ImportError saying no module named 'arduino'. I am using the newest linux with everything updated. Can anyone explain why this is happening? let me know if I need to give you more information, I am very new to programming.
Reply
#2
Why would it work? Have you installed a module? Are you reading a tutorial that suggests it should work? And please include the exact code you're using, even if it's a single line.
Reply
#3
#!/usr/bin/python3
import arduino
def loop():
 contin = True
 while contin:
  quitstatement = input()
  if quitstatement == false:
  else:
   arduino.send()
   contin = false
 pass
def main():
 arduino.connect()
 loop()
 arduino.disconnect()
if __name__ == "__main__":
 main()
That is the code that was provided by a professor, who did not give any other instructions regarding installing a module. 
Thank you very much, being new to programming can be tough!
Reply
#4
It looks like you need to install this. On Linux, you can install it with
pip install arduino-python
You may need to use sudo. This should solve the ImportError.
Reply
#5
Including the exact (cut and past, verbatim) error message will go a long way to solving the error.

what you are saying points in the direction of a missing package that you must install.

I can not find a package named arduino (by itself), there are plenty of arduino packages with other names

see https://pypi.python.org/pypi? search for arduino
Reply
#6
Error remains: 

ImportError: No module named 'arduino'


I tried pip install arduino-python, but received

error: could not create '/usr/local/lib/python2.7/dist-packages/Arduino': Permission denied



I also tried sudo apt-get install arduino
and installing a package from online and none of those worked. Thank you for the suggestions
Reply
#7
If you have access to root, you will probably need to precede your command with 'sudo'
Reply
#8
You should talk to whoever you got the script from. I just noticed they use false instead of False (casing matters), so I'm concerned there may be other issues as well, so you might as well hear it straight from the author.
Reply
#9
I didn't look at the script before, but after micseydel's last post, I took a look.
There are all kinds of things that will trash this script .. an if followed immediately by an else
a pass out of place (probably went after the if mentioned above).

Looks like you have some work to do after you get the package imported
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020