You are not logged in.
Hi, i am trying to run a python script, but every time i try to run it
with ./unlocker.py i get
File "./unlocker.py", line 31
print 80 * "*"
^
SyntaxError: invalid syntax
dreadz ~ > which python
/usr/bin/python
I have consulted with the wiki, and attempted all solutions there
to deal with the enviroment problems. If i use virtualenv2 i get this
Traceback (most recent call last):
File "./unlocker.py", line 27, in <module>
import time, serial, re, hashlib, glob
ImportError: No module named serial
(venv)dreadz ~/builds > which python
/home/dreadz/builds/venv/bin/python
(venv)dreadz ~/builds >
The script runs on a solaris system but not on mine.
Maybe someone can point me to a solution ?
dreadz ~/builds > uname -a
Linux ufoo 3.13.5-1-ARCH #1 SMP PREEMPT Sun Feb 23 00:25:24 CET 2014 x86_64 GNU/Linux
Thanks
Last edited by dreadz (2014-02-28 10:04:08)
Offline
Are you running Python2 on one system and Python3 on another?
Matt
"It is very difficult to educate the educated."
Offline
The solaris system is in the uni, so i don't know
what version of python is running there.
That's what i have on mine
dreadz ~/builds > python --version
Python 3.3.4
Offline
The solaris system is in the uni, so i don't know
The version of Python on Solaris is almost certainly Python 2.
print 80 * "*"
This is correct syntax for Python 2.
This is NOT correct syntax for Python 3. In Python 3, "print" is a function.
Offline
If i change the shebang line to:
#!/usr/bin/env python2
i get the Traceback error.
If i run with
python2 script.py
i get the same error.
Offline
If i change the shebang line to:
#!/usr/bin/env python2
i get the Traceback error.
If i run with
python2 script.py
i get the same error.
Traceback (most recent call last):
File "./unlocker.py", line 27, in <module>
import time, serial, re, hashlib, glob
ImportError: No module named serial
The error is extremely descriptive. Read it again. What is it telling you? What might that mean? What would be the most reasonable solution?
Last edited by jakobcreutzfeldt (2014-02-25 16:02:51)
Offline
The error is extremely descriptive. Read it again. What is it telling you? What might that mean? What would be the most reasonable solution?
I don't mean to be dissrespecting but i have read the error and it is not descriptive to me.
I don't have experience with python, i am only trying to run a script that i know for a fact can
run on another system. I know it is something to do with my env path and the solutions to simmilar
problem described in the wiki do not work on my system.
Offline
"ImportError: No module named serial" is pretty clear, you don't have the serial module installed.
Offline
python2 script.py
Traceback (most recent call last): File "./unlocker.py", line 27, in <module> import time, serial, re, hashlib, glob ImportError: No module named serial
"No module name serial" means there is no module named "serial".
If you want to use a module named "serial" then you will need to install a module named "serial". Keep in mind that the module will need to be installed for Python 2.
Offline
"No module name serial" means there is no module named "serial".
If you want to use a module named "serial" then you will need to install a module named "serial". Keep in mind that the module will need to be installed for Python 2.
Thanks for pointing this out. I have installed python2-pyserial and now i can run the script.
Thanks for your patience and advice!
Offline
You're welcome. You can add "[SOLVED]" to the title of this thread by editing your original post.
Yeah, even after all this time Arch Linux is STILL one of the only distributions that switched to Python 3 as the default version. Tricky Arch Linux. Keeps me on my toes.
Offline