Can't get a python script off the ground, involves pyserial

amddude

Golden Member
Mar 9, 2006
1,711
1
81
Hi,

I'm trying to run a python script:

import serial
ser = serial.Serial('COM35', 9600, timeout=1)
ser.open
ser2 = serial.Serial('COM36', 9600, timeout=1)
ser2.open
print "ports opened"
while 1:
freqency = ser.readline()
print "read" + freqency
freqency = "FA0" + freqency[2:12] +";"
if len(freqency) > 13:
ser2.write(freqency)
ser2.write(freqency)
ser2.write(freqency)
print freqency




I did not write it. I have python 2.7 installed and pyserial 2.6. Pyserial installed without any errors.

When I go to run the script I get this error:
C:\Python27>python C:\uni.py
Traceback (most recent call last):
File "C:\uni.py", line 1, in <module>
import serial
ImportError: No module named serial


The platform is windows 7 x64. I would really appreciate any help here. I think I'm close.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Seems like the Serial libraries are not in the path to be loaded
 

amddude

Golden Member
Mar 9, 2006
1,711
1
81
Seems like the Serial libraries are not in the path to be loaded

We're talking like, path variables, environment variables right?

If so I'm not sure which folder to set it as. When I installed pyserial it put pyserial-2.6-py2.7.egg-info in C:\Python27\Lib\site-packages

Is that the folder I should path as serial? I apologize if I'm being dense.

Edit: I have python and pythonpath pathed to C:\Python27;C:\Python27\DLLs;C:\Python27\Lib
 
Last edited:

esun

Platinum Member
Nov 12, 2001
2,214
0
0
How did you install pyserial? Did you manually run the setup.py script, did you use easy_install, or did you use pip? Or did you use some other method?

I would try just going to a command prompt and typing:

easy_install pyserial

There's a decent chance that will work (requires Internet connectivity). If it works you should have a directory called pyserial (or possibly just a pyserial.py file) within your site-packages directory.

EDIT: To clarify, when you do 'import package' in Python, it searches your PYTHONPATH for either a python file called 'package.py' or for a directory called 'package' containing an '__init__.py' file. If one of those things is not present in your PYTHONPATH, you get the error you're seeing.
 

amddude

Golden Member
Mar 9, 2006
1,711
1
81
How did you install pyserial? Did you manually run the setup.py script, did you use easy_install, or did you use pip? Or did you use some other method?

I would try just going to a command prompt and typing:

easy_install pyserial

There's a decent chance that will work (requires Internet connectivity). If it works you should have a directory called pyserial (or possibly just a pyserial.py file) within your site-packages directory.

EDIT: To clarify, when you do 'import package' in Python, it searches your PYTHONPATH for either a python file called 'package.py' or for a directory called 'package' containing an '__init__.py' file. If one of those things is not present in your PYTHONPATH, you get the error you're seeing.

I downloaded the package from the developer's site, decompressed, and ran setup.py.

I went into python in command line and did easy_install pyserial and got a syntax error. I also tried doing 'python easy_install pyserial" and had the same problem. What am I missing?