Hi,
I am having difficulty importing python modules into Zen 2012 for the macro environment. I am getting 'ArgumentOutOfRangeException: Value must be between 1 and ...
Parameter name: number
Actual value was ...
I am able to import simple modules, but once the packages I import require other modules, a problem occurs. One example of a module I would like to be able to use is pySerial.
I start by adding the Python27\lib and \lib\site -packages directories to sys.path, and then import the module.
Am I incorrectly loading the python modules into Zen's ironPython ? Please advise.
Thank you
Importing python packages
Hi,
can you post the macro code, because for me this works fine in an OAD macro.
can you post the macro code, because for me this works fine in an OAD macro.
Code: Select all
import sys
sys.path.append(r'C:\Python27\Lib\site-packages')
# check where Zen is looking for stuff
print sys.path
import serial as ps
print 'OK'
Code: Select all
import sys
import serial
from time import sleep
sys.path.append(r'C:\Python27\Lib\site-packages')
ser = serial.Serial(2)
print ser.portstr
print ser
ser.write("/1V300000R\r\n")
sleep(1)
ser.write("/1z4550000R\r\n")
sleep(1)
ser.write("/1P4550000R\r\n")
ser.close()
Code: Select all
COM4
Serial<id=0x2f, open=True>(port='COM4', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)
Code: Select all
ArgumentOutOfRangeException: Value must be between 1 and 16
Parameter name: number
Actual value was 44
This code works fine in the python shell for the device on COM4
Hi,
Is there any update on this issue?
Is there any update on this issue?
Carl Zeiss Microscopy 6 wrote:Hi,
can you post the macro code, because for me this works fine in an OAD macro.
Code: Select all
import sys sys.path.append(r'C:\Python27\Lib\site-packages') # check where Zen is looking for stuff print sys.path import serial as ps print 'OK'
Hello,
It is very difficult for us to verify your question as we do not have your environment.
Please assure that you compare the very same versions of IronPython.
Sorry, but it seems that we cannot offer more help.
Maybe this theme is related to your problem
http://stackoverflow.com/questions/3024760/pyserial-and-ironpython-get-strange-error
It is very difficult for us to verify your question as we do not have your environment.
Please assure that you compare the very same versions of IronPython.
Sorry, but it seems that we cannot offer more help.
Maybe this theme is related to your problem
http://stackoverflow.com/questions/3024760/pyserial-and-ironpython-get-strange-error
Thank you for your response. However, I have looked at that link before and it does not apply to my situation.Carl Zeiss Microscopy 3 wrote:Hello,
It is very difficult for us to verify your question as we do not have your environment.
Please assure that you compare the very same versions of IronPython.
Sorry, but it seems that we cannot offer more help.
Maybe this theme is related to your problem
http://stackoverflow.com/questions/3024760/pyserial-and-ironpython-get-strange-error
It looks like you installed the module in the previous response, so were you able to load the python module and write() commands to any serial device? (Rather than just import the module and not actually use the most important part Seria.write() ! )
I ended up using system.io.ports.serialport (from System import *) and will not likely need any other python modules for my project, but it is worth nothing that I was getting a similar error from other imported python Modules in zen.
No module named serial
Hi, I tried to import the serial module into the ZEN2.3 Macor Editor.
------------------------------
# import serial
import sys
sys.path.append(r'C:\Python27\Lib\site-packages')
# check where Zen is looking for stuff
print sys.path
import serial as ps
print 'OK'
-------------------------------
However I get the error message: No module named serial.
I have Python2.7 installed with the pyserial package in the specified path.
Any suggestions?
Christian
------------------------------
# import serial
import sys
sys.path.append(r'C:\Python27\Lib\site-packages')
# check where Zen is looking for stuff
print sys.path
import serial as ps
print 'OK'
-------------------------------
However I get the error message: No module named serial.
I have Python2.7 installed with the pyserial package in the specified path.
Any suggestions?
Christian