ImportError: No module named json_tricks

Hi everyone,

I’m new to psychopy and installed standalone psychopy on
ubuntu using

sudo apt-get install psychopy.

When I try to open the Monitor Center in the psychopy coder GUI I get

ImportError: No module named json_tricks

even though json_tricks is installed and it is possible to open the Monitor Center in the builder GUI without getting this error. Furthermore the same error occurs every time I try to run any script in psychopy builder or coder (including the demo scripts).

Has anyone any suggestions what could have gone wrong during installation or why psychopy is not able to import json_tricks?

Thank you for any help or idea!

Most likely you’ve ended up with multiple python installations and json_tricks is installed in one but not the other. You can find out which python is being used as below, so you could test that from within Coder and from your terminal, to see if they differ:

import sys
print(sys.executable)

Thank you for your response! You pointed me to the right direction. I had two different python versions installed and json_tricks was installed only in one of them and not in the one psychopy used. So I installed it in the other version too and now everything works perfectly.

Hi,

I’m getting same error:

brain@neurodebian:/usr/lib/python2.7$ python …/…/…/home/brain/Desktop/exp.py
Traceback (most recent call last):
File “…/…/…/home/brain/Desktop/exp.py”, line 8, in
from psychopy import visual, event, core, data
File “/usr/lib/python2.7/dist-packages/psychopy/visual/init.py”, line 17, in
from .window import Window, getMsPerFrame, openWindows
File “/usr/lib/python2.7/dist-packages/psychopy/visual/window.py”, line 57, in
from psychopy import core, platform_specific, logging, prefs, monitors, event
File “/usr/lib/python2.7/dist-packages/psychopy/monitors/init.py”, line 5, in
from .calibTools import *
File “/usr/lib/python2.7/dist-packages/psychopy/monitors/calibTools.py”, line 34, in
import json_tricks # allows json to dump/load np.arrays and dates
ImportError: No module named json_tricks
brain@neurodebian:/usr/lib/python2.7$

When running suggested command I get like this:
>>> import sys
>>> print(sys.executable)
/usr/bin/python
>>>

It seems that multiple pythons are installed on my machine also.

I’m not sure how to continue as jon described! May you tell me what to exactly do? How to bypass this?

I think you can execute pip as a module using the -m flag in Python and that means you can specify directly which pip is used (whereas calling pip install xxxx will just use the first instance of pip found on the system path). So try doing this to install json_tricks into the python that you are actually using

python -m pip install json_tricks

or even

/usr/bin/python -m pip install json_tricks

I get the same error as the 2 other posters. It seems that my pip leads to my conda installation by default.

Running (inside the coder)

import sys
print(sys.executable)

returns

/usr/bin/python

but when I try

/usr/bin/python -m pip install json_tricks

it returns

/usr/bin/python: No module named pip

Is there a way for me to address this? Tried to reinstall psychopy to no avail.