easy way to add python packages to standalone version of PsychoPy?

1,175 views
Skip to first unread message

piot

unread,
Apr 19, 2016, 3:47:56 PM4/19/16
to psychopy-users
Hello all,

is there an easy way to add python packages to the standalone version of PsychoPy?

I've written our experiments under linux, but our lab pcs are running windows. I wanted to go for an easy way to install PsychoPy (standalone version) on our lab pcs. I've started using pandas (originally because of TrialHandler2) in my experiment and I'm loading some data files with pandas.read_excel().

Now Python complains, that no module named xlrd is available on the standalone version of PsychoPy. (ImportError: No module named xlrd)

C:\Program Files (x86)\Psychopy2\lib\site-packages\pandas\io\excel.py has 'import xlrd' on line 169, but the xlrd module doesn't seem to be included in PsychoPy (Standalone)...

Wouldn't it be a good idea to add it to PsychoPy (Standalone), if it is referenced?

What's the easiest fix for now?

Best wishes
Piotr

piot

unread,
Apr 19, 2016, 4:41:49 PM4/19/16
to psychopy-users
ok, I've just copied the xlrd modules from linux to the modules dir of PsychoPy (Standalone) and it works. Would be nice, if it was added by default..

Jonathan Peirce

unread,
Apr 20, 2016, 5:12:04 AM4/20/16
to psychop...@googlegroups.com
The other thing you can do is add the location of the other package to your python path (list of locations where import searches). This can be done in several ways including:
    - import sys; sys.path.append("/path/to/your/custom/location")
    - add the path to psychopy preferences and then import psychopy at the top of your script (which will then do the same as above)
These solutions also mean you can add things in your home directory (like your home-grown toolkits)

Adding *all* your other python packages by default is probably a bad idea. If you have packages installed that aren't compatible (e.g. newer or older versions or built for the wrong architecture) then you could some confusing bugs.

cheers
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/0d501dda-f73d-41b9-a406-6d1586546bc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
University of Nottingham

http://www.peirce.org.uk


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.

piot

unread,
Apr 20, 2016, 7:31:40 AM4/20/16
to psychopy-users
Thanks a lot, Jon!

piot

unread,
May 17, 2016, 2:51:18 PM5/17/16
to psychopy-users
Dear Jon,

I have a similar problem. Maybe you can help me out with that one. I got used to pandas and save some data concerning the order of trials in an excel file with the pandas to_excel command. It works under linux, but I have problems on the standalone version of psychopy on windows 7.

I get the following error:

Traceback (most recent call last):
  File "E:\dfg_win\main.py", line 105, in <module>
    order_df.to_excel(filename_order, header=True, encoding='utf-8', index=False)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pandas\core\frame.py", line 1260, in to_excel
    excel_writer = ExcelWriter(excel_writer, engine=engine)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pandas\io\excel.py", line 635, in __init__
    .format(self.openpyxl_majorver))
ValueError: Installed openpyxl is not supported at this time. Use 1.x.y.

Openpyxl-1.5.8 is installed, so that's strange. I tried copying my version of openpyxl from Linux as well as installing different versions of openpyxl but get always some kind of error. Do you know any simple way to get around the problem?

For now I just use to_csv instead and it works, so it's not a big deal, but if you know a way to solve it, I would appreciate it.

best wishes
Piotr

Jonathan Peirce

unread,
May 18, 2016, 6:34:16 AM5/18/16
to psychop...@googlegroups.com
It's rare to be able to just copy over the package from a different operating system (except for packages that are pure python code)

More likely you'd be able to install the latest version of openpyxl in a different (but still version 2.7) installation of Python in you windows install and then copy that over to the Standalone.

BUT I'm currently building a new standalone windows release and it will have xlrd and openpyxl included so your particular issue should disappear

Jon

For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

piot

unread,
May 18, 2016, 7:19:54 AM5/18/16
to psychopy-users
thanks for the info, Jon.

I really appreciate it!

piotr
Reply all
Reply to author
Forward
0 new messages