Re: question about serial port

483 views
Skip to first unread message

Jonathan Peirce

unread,
Dec 7, 2010, 1:54:20 PM12/7/10
to Mingbo Cai, psychop...@googlegroups.com
I'll make sure that release 1.63.00 has serial included again.

But for now:
The serial package that you've installed has gone to the system python. Standalone PsychoPy includes an entirely separate python that doesn't talk to your system one. If you right-click the psychopy app and navigate to the resources/lib/site-packages (or something along those lines) you can paste in there the pyserial folder from your system site-packages. For some packages that doesn't work but for pyserial i think it's fine.

Jon

On 07/12/2010 18:25, Mingbo Cai wrote:

Hi Dr Peirce,

I am working with David Eagleman and trying to use pyshopy on a mac. The problem I have got is that: I need to use a serial port but an error always occur on the line of �import serial�. It says there is no such module of serial.

�

The version of Mac OS X is 10.6.4, and I downloaded the standalone Psychopy of 1.62.01-OSX.10.6, installed it and updated to 1.62.02. Since it had that error, I then downloaded pyserial 2.5 to install; it still had that error. Then I found that somewhere on the website said I should use pyserial 2.4, then I go ahead to download and install 2.4, but the error is still the same. Do you have any clue how this can be solved? BTW, When I typed python in an X11 terminal, and then typed help(), then modules(serial), I can see that serial is there with 2.4 version.

�

(don�t worry about the available serial port on Mac, I have got a USB � serial adaptor and installed a drive that works on another older Mac)

�

�

Thanks very much,

Mingbo Cai

Eagleman Lab

Department of Neuroscience

Baylor College of Medicien


-- 
Dr. Jonathan Peirce
Associate Professor
Nottingham Visual Neuroscience
School of Psychology
Nottingham University

+44 (0)115 8467176 (tel)
http://www.peirce.org.uk/

jason gors

unread,
Dec 7, 2010, 3:56:47 PM12/7/10
to psychop...@googlegroups.com
hey mingbo,
john's suggestion is a good way go, however, alternatively, if you
wanted more external modules later down the line, you could put a .pth
file inside the psychopy app and configure it to look for module
imports outside of psychopy. thus, you could just list the directory
path for whatever extra module you might want (in this case, pyserial)
inside the .pth file and it should import the module from the path you
list (if you just wanted pyserial, then john's suggestion is probably
the best way to go, but for several external modules, this might be
easier to keep track of everything). ...it *should* work.

also, you could dynamically change(/add to) the search path of your
script at the top of the script and it should import the module you
want as well:

# this should append the pyserial module to your
# system's(/psychopy's) search when you run the script
import sys
sys.path.append("wherever/the/pyserial/module/resides")

I think these should work...

--jason


---
Jason Gors
Dartmouth College
Dept. of Psychological and Brain Sciences
6207 Moore Hall
Hanover, NH 03755
Phone: (603) 646-9689    Fax: (603) 646-1419

On Tue, Dec 7, 2010 at 1:54 PM, Jonathan Peirce <jon.p...@gmail.com> wrote:
> I'll make sure that release 1.63.00 has serial included again.
>
> But for now:
> The serial package that you've installed has gone to the system python.
> Standalone PsychoPy includes an entirely separate python that doesn't talk
> to your system one. If you right-click the psychopy app and navigate to the
> resources/lib/site-packages (or something along those lines) you can paste
> in there the pyserial folder from your system site-packages. For some
> packages that doesn't work but for pyserial i think it's fine.
>
> Jon
>
> On 07/12/2010 18:25, Mingbo Cai wrote:
>
> Hi Dr Peirce,
>
> I am working with David Eagleman and trying to use pyshopy on a mac. The
> problem I have got is that: I need to use a serial port but an error always

> occur on the line of “import serial”. It says there is no such module of
> serial.
>
>
>


> The version of Mac OS X is 10.6.4, and I downloaded the standalone Psychopy
> of 1.62.01-OSX.10.6, installed it and updated to 1.62.02. Since it had that
> error, I then downloaded pyserial 2.5 to install; it still had that error.
> Then I found that somewhere on the website said I should use pyserial 2.4,
> then I go ahead to download and install 2.4, but the error is still the
> same. Do you have any clue how this can be solved? BTW, When I typed python
> in an X11 terminal, and then typed help(), then modules(serial), I can see
> that serial is there with 2.4 version.
>
>
>

> (don’t worry about the available serial port on Mac, I have got a USB –


> serial adaptor and installed a drive that works on another older Mac)
>
>
>
>
>

> Thanks very much,
>
> Mingbo Cai
>
> Eagleman Lab
>
> Department of Neuroscience
>
> Baylor College of Medicien
>
> --
> Dr. Jonathan Peirce
> Associate Professor
> Nottingham Visual Neuroscience
> School of Psychology
> Nottingham University
>
> +44 (0)115 8467176 (tel)
> http://www.peirce.org.uk/
>

> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to
> psychopy-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/psychopy-users?hl=en.
>

Jonathan Peirce

unread,
Dec 8, 2010, 5:07:26 AM12/8/10
to psychop...@googlegroups.com
Quite right. Inserting .pth files into your site-packages is a great way
to add to your path, and is also useful for importing your own custom
functions that you end up rewriting for every experiment/analysis.

hmm, actually, maybe PsychoPy should have an 'path' menu option or
preference, to make this concept more obvious.

Jon

>> occur on the line of �import serial�. It says there is no such module of


>> serial.
>>
>>
>>
>> The version of Mac OS X is 10.6.4, and I downloaded the standalone Psychopy
>> of 1.62.01-OSX.10.6, installed it and updated to 1.62.02. Since it had that
>> error, I then downloaded pyserial 2.5 to install; it still had that error.
>> Then I found that somewhere on the website said I should use pyserial 2.4,
>> then I go ahead to download and install 2.4, but the error is still the
>> same. Do you have any clue how this can be solved? BTW, When I typed python
>> in an X11 terminal, and then typed help(), then modules(serial), I can see
>> that serial is there with 2.4 version.
>>
>>
>>

>> (don�t worry about the available serial port on Mac, I have got a USB �


>> serial adaptor and installed a drive that works on another older Mac)
>>
>>
>>
>>
>>
>> Thanks very much,
>>
>> Mingbo Cai
>>
>> Eagleman Lab
>>
>> Department of Neuroscience
>>
>> Baylor College of Medicien
>>
>> --


This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

jason gors

unread,
Dec 8, 2010, 9:11:44 AM12/8/10
to psychop...@googlegroups.com
Hey Jon,
I was recently helping a colleague with this same issue in psychopy
(particularly, he wanted to add/import pyserial to detect scanner
triggers) and he asked me the very same point you raise -- about
having some type of menu option in the coder to aid in importing
external modules. Yeah, for one module (i.e. pyserial) it's easy
enough to get around, but if folks wanted to add several external
modules, it might help keep things simpler to have a 'path' menu
option that could append to the current sys.path() or maybe write to a
.pth file. However, as per pyserial, if it's in the upcoming release,
yep, all is good. :)

--jason

---
Jason Gors
Dartmouth College
Dept. of Psychological and Brain Sciences
6207 Moore Hall
Hanover, NH 03755
Phone: (603) 646-9689    Fax: (603) 646-1419

>>> occur on the line of “import serial”. It says there is no such module of


>>> serial.
>>>
>>>
>>>
>>> The version of Mac OS X is 10.6.4, and I downloaded the standalone
>>> Psychopy
>>> of 1.62.01-OSX.10.6, installed it and updated to 1.62.02. Since it had
>>> that
>>> error, I then downloaded pyserial 2.5 to install; it still had that
>>> error.
>>> Then I found that somewhere on the website said I should use pyserial
>>> 2.4,
>>> then I go ahead to download and install 2.4, but the error is still the
>>> same. Do you have any clue how this can be solved? BTW, When I typed
>>> python
>>> in an X11 terminal, and then typed help(), then modules(serial), I can
>>> see
>>> that serial is there with 2.4 version.
>>>
>>>
>>>

>>> (don’t worry about the available serial port on Mac, I have got a USB –


>>> serial adaptor and installed a drive that works on another older Mac)
>>>
>>>
>>>
>>>
>>>
>>> Thanks very much,
>>>
>>> Mingbo Cai
>>>
>>> Eagleman Lab
>>>
>>> Department of Neuroscience
>>>
>>> Baylor College of Medicien
>>>
>>> --
>
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do not
> use, copy or disclose the information contained in this message or in any
> attachment.  Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>

Andy

unread,
Dec 8, 2010, 10:52:57 AM12/8/10
to psychopy-users
Hi Jon,

Thanks for all your great work on PsychoPy!

I second the idea of having a 'path' menu option. This would allow
users to add packages (either custom made or standard downloads) which
could live in a folder that does not get wiped clean with each new
PsychoPy update.
Is there a "safe" place to put packages (or a file with path
extensions) so that they won't be wiped out upon upgrade? I just put
stuff in /Applications/PsychoPy2.app/Contents/Resources/lib/
python2.5 , but Jason tells me these will be wiped out when I upgrade
PsychoPy.

As a python and Mac user who is relatively new to PsychoPy, I am a
little confounded by the standalone environment - mostly because I
don't have access to my system python with all of the packages I have
installed, including custom utility packages.
The fixes suggested are good as long as they can survive Psychopy
upgrades. But path extensions and pasting in code from site-packages
(system) to site-packages (PsychoPy) will only work for packages
without special (e.g. clib) dependencies. For these latter types, it
would also be useful for psychopy to have an easy way to build/install
new packages. These new packages could also reside in a site-packages
folder that would be protected upon upgrade.

While I am at it, here are couple other things on my wish list for
future PsychoPy release:
(1) Packages:
pyserial (right now I already have it on PsychoPy v1.62.01 on Mac
OS 10.5.8)
parallel python (I have it on my system but not in psychopy
python)
(2) An Ipython terminal that you can launch from the PsychoPy GUI that
would be running PsychoPy's python. This would be helpful for testing
bits of code; it would let users interrogate the contents of the 'new'
python environment; and it would make me feel more at home as a python
programmer using PsychoPy.

Note: Most of my issues would be resolved (so the guys across the hall
tell me) if I were to switch to a system with a comprehensive package
manager that also packaged PsychoPy (i.e., NeuroDebian), but for now I
am still a Mac user stubbornly holding my ground.

Thanks again!

andy


On Dec 8, 9:11 am, jason gors <jason.d.g...@dartmouth.edu> wrote:
> Hey Jon,
> I was recently helping a colleague with this same issue in psychopy
> (particularly, he wanted to add/import pyserial to detect scanner
> triggers) and he asked me the very same point you raise -- about
> having some type of menu option in the coder to aid in importing
> external modules.  Yeah, for one module (i.e. pyserial) it's easy
> enough to get around, but if folks wanted to add several external
> modules, it might help keep things simpler to have a 'path' menu
> option that could append to the current sys.path() or maybe write to a
> .pth file.  However, as per pyserial, if it's in the upcoming release,
> yep, all is good.  :)
>
> --jason
>
> ---
> Jason Gors
> Dartmouth College
> Dept. of Psychological and Brain Sciences
> 6207 Moore Hall
> Hanover, NH 03755
> Phone: (603) 646-9689    Fax: (603) 646-1419
>
> On Wed, Dec 8, 2010 at 5:07 AM, Jonathan Peirce
>
> >> On Tue, Dec 7, 2010 at 1:54 PM, Jonathan Peirce<jon.pei...@gmail.com>

Jonathan Peirce

unread,
Dec 8, 2010, 12:41:55 PM12/8/10
to psychop...@googlegroups.com

On 08/12/2010 15:52, Andy wrote:
> Hi Jon,
>
> Thanks for all your great work on PsychoPy!
>
> I second the idea of having a 'path' menu option. This would allow
> users to add packages (either custom made or standard downloads) which
> could live in a folder that does not get wiped clean with each new
> PsychoPy update.
> Is there a "safe" place to put packages (or a file with path
> extensions) so that they won't be wiped out upon upgrade? I just put
> stuff in /Applications/PsychoPy2.app/Contents/Resources/lib/
> python2.5 , but Jason tells me these will be wiped out when I upgrade
> PsychoPy.
>
>

Jason's right, we need to setup a path possibility in user prefs to make
it resilient to upgrades of the standalone psychopy. Actually, upgrades
that are installed automatically are fine. But major upgrades (with a
new binary) will not have your .pth file.


> As a python and Mac user who is relatively new to PsychoPy, I am a
> little confounded by the standalone environment - mostly because I
> don't have access to my system python with all of the packages I have
> installed, including custom utility packages.
> The fixes suggested are good as long as they can survive Psychopy
> upgrades. But path extensions and pasting in code from site-packages
> (system) to site-packages (PsychoPy) will only work for packages
> without special (e.g. clib) dependencies. For these latter types, it
> would also be useful for psychopy to have an easy way to build/install
> new packages. These new packages could also reside in a site-packages
> folder that would be protected upon upgrade.
>

I looked into the possibility of having psychopy actually install
packages from other places to itself and it didn't work well at all.
But I think that experienced users, that already know how to install
packages, could just use psychopy from their own python. You can install
it with easy_install and then you 'just' have to get all the
dependencies. The standalone is designed very much for the people that
want to see an application rather than a framework.


> While I am at it, here are couple other things on my wish list for
> future PsychoPy release:
> (1) Packages:
> pyserial (right now I already have it on PsychoPy v1.62.01 on Mac
> OS 10.5.8)
>

agreed


> parallel python (I have it on my system but not in psychopy
> python)
>

do you mean pyparallel (for communication with the parallel port) or do
you actually mean parallel python (for running multiple processes? Only
the former really makes sense for psychopy in my view. I don't want to
include all possible packages for use with python - just the ones useful
for psych/vision/neuro experiments. Otherwise I'll spend my life just
doing packaging.


> (2) An Ipython terminal that you can launch from the PsychoPy GUI that
> would be running PsychoPy's python. This would be helpful for testing
> bits of code; it would let users interrogate the contents of the 'new'
> python environment; and it would make me feel more at home as a python
> programmer using PsychoPy.
>

Yes, am planning to add a shell like this, but it may be the pycrust
shell instead of ipython - I think that will be easier so get included
quicker. Happy to be corrected if someone knows how to build ipython
into a wx app.

all the best,
Jon

Andrew Connolly

unread,
Dec 8, 2010, 3:47:52 PM12/8/10
to psychop...@googlegroups.com

    parallel python (I have it on my system but not in psychopy
python)
 
do you mean pyparallel (for communication with the parallel port) or do you actually mean parallel python (for running multiple processes? Only the former really makes sense for psychopy in my view. I don't want to include all possible packages for use with python - just the ones useful for psych/vision/neuro experiments. Otherwise I'll spend my life just doing packaging.

I meant parallel python (pp). I used this in combination with pyserial to write a parallel "serial track" routine to work with a PyEPL fMRI presentation script so that I could record trigger pulses and subject button presses without interrupting the flow of the experiment. I want to write a similar routine to work with psychopy.

I have heard rumors that PsychoPy will eventually incorporate the automatic logging (of everything) in a similar fashion as PyEPL, i.e., videoTrack, keyboardTrack, serialTrack(?). I hope this is true.  This was a great feature of PyEPL and it would be great to have in psychopy.

best,
Andy
 


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.




--
Andrew C. Connolly, Ph.D.
Psychological and Brain Sciences
Dartmouth College

6207 Moore Hall
Hanover, NH 03755
603-646-6436

Jonathan Peirce

unread,
Dec 9, 2010, 4:51:02 AM12/9/10
to psychop...@googlegroups.com

> I have heard rumors that PsychoPy will eventually incorporate the
> automatic logging (of everything) in a similar fashion as PyEPL, i.e.,
> videoTrack, keyboardTrack, serialTrack(?). I hope this is true. This
> was a great feature of PyEPL and it would be great to have in psychopy.
>
The steps are:
1. create the hooks in psychopy to allow automated logging of large
numbers of messages, with minimal overhead, timestamped to the frame on
which they occurred (or simply the current time if not related to a frame)
2. add calls to the various objects to send the log messages
3. choose how to format the log files

1 is the tricky part, but it's done and about to be released
2 has begun and will happen gradually as we think of more things that
could be logged
3 will evolve over the next couple of versions of psychopy.

Jon

Jonathan Peirce

unread,
Dec 9, 2010, 6:14:50 AM12/9/10
to psychop...@googlegroups.com

>> (2) An Ipython terminal that you can launch from the PsychoPy GUI that
>> would be running PsychoPy's python. This would be helpful for testing
>> bits of code; it would let users interrogate the contents of the 'new'
>> python environment; and it would make me feel more at home as a python
>> programmer using PsychoPy.
> Yes, am planning to add a shell like this, but it may be the pycrust
> shell instead of ipython - I think that will be easier so get included
> quicker. Happy to be corrected if someone knows how to build ipython
> into a wx app.
OK, I'll corrected myself. It looks like it's pretty easy to insert an
interactive ipython shell into psychopy. The question is how we prefer
to do it:
1. We could *replace* the current output panel with an ipython
shell (the same view would receive output from scripts as well as being
a receptacle of python/ipython commands. The hack below does roughly
this - the slight issue is that while a script is run we don't want
ipython to read the script outputs as commands(!)
2. We could have a pair of panels in the bottom of the Coder view,
one for shell interaction and another for script output.

This development is too sudden for me to add it in this release - I want
to do some thinking and testing first. But for those that want to have a
look at option 1 above, all you need to do is go to
psychopy/app/coder/coder.py and change the lines around 940 to look like
this:

#create output viewer
self._origStdOut = sys.stdout#keep track of previous output
self._origStdErr = sys.stderr
# self.outputWindow =
stdOutRich.StdOutRich(self,style=wx.TE_MULTILINE|wx.TE_READONLY,
size=wx.Size(400,400))
# self.outputWindow.write('Welcome to PsychoPy2!\n')
# self.outputWindow.write("v%s\n" %self.app.version)

import IPython.gui.wx.ipython_view
self.outputWindow =
IPython.gui.wx.ipython_view.IPShellWidget(parent=self,
background_color='WHITE')
#turn off threading - interferes with pygame thread
self.outputWindow.options['threading']['value']='False'
self.outputWindow.IP.set_threading(False)
self.outputWindow.threading_option.SetValue(False)
#allow a write fmethod for the window
self.outputWindow.cout.write = self.outputWindow.text_ctrl.write
self.outputWindow.write = self.outputWindow.text_ctrl.write
#set background to white

self.outputWindow.options['background_color']['value']='WHITE'#this
setting isn't used by __init__ apparently

self.outputWindow.text_ctrl.setBackgroundColor(self.outputWindow.options['background_color']['value'])
self.outputWindow.background_option.SetValue(True)
self.outputWindow.updateOptionTracker('background_color',

self.outputWindow.options['background_color']['value'])
#scintilla autocompletion method
self.outputWindow.completion_option.SetValue(True)
self.outputWindow.options['completion']['value']='STC'

self.outputWindow.text_ctrl.setCompletionMethod(self.outputWindow.options['completion']['value'])
self.outputWindow.updateOptionTracker('completion',

self.outputWindow.options['completion']['value'])
self.outputWindow.text_ctrl.SetFocus()


--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

jason gors

unread,
Dec 9, 2010, 9:04:35 AM12/9/10
to psychop...@googlegroups.com
Hey Jon,
Having ipython built right into psychopy would be great, as I usually
have a terminal running ipython next to psychopy to test code snippets
anyways, however, I'm not sure what the "vision" is here (bad pun for
vision scientists ;). My vote would be for something like (2), like
gedit has: a main text editor, and at the bottom, an output pane for
the editor, a python interpreter, a terminal pane, etc -- that can be
toggled between. However, in psychopy's case, (instead of like gedit
w/ the regular python interpreter, terminal, and all that other stuff)
there'd just be an ipython pane alongside the output pane. I think
this keeps things tidy with only these 2 things -- with one to see the
script's outputs and another to do code snippet testing. I know gedit
isn't the best to go off of from a wx standpoint, but I just mention
as a stylistic example. Your (1) sounds really nice, but it's not
clear to me why this might be preferable -- perhaps just to keep
things in one place so a keyboard shortcut could more easily/quickly
move between the editor and the output/ipython pane (so long as the
problem you point out is avoided of course), but I've only just used
text editors that keep the script's output in a separate place/pane
from the built-in python interpreter part.

Either way, like Andy, I think having ipython would be really great;
also, this is only slightly related, but if folks are interested in
just doing smallish code snippet testing, I find Reinteract really
nice for this.

--jason

---
Jason Gors
Dartmouth College
Dept. of Psychological and Brain Sciences
6207 Moore Hall
Hanover, NH 03755
Phone: (603) 646-9689    Fax: (603) 646-1419

Jonathan Peirce

unread,
Dec 9, 2010, 10:25:20 AM12/9/10
to psychop...@googlegroups.com
A combined window is the way matlab works, and it has a simplicity that
appeals to me. But having a separate tab in the bottom panel is easier
to implement, so maybe I'll just do that.

On 09/12/2010 14:04, jason gors wrote:
> Your (1) sounds really nice, but it's not
> clear to me why this might be preferable

--

Dr. Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/


Reply all
Reply to author
Forward
0 new messages