We're Hiring!

Uploading script error: cannot import other scripts

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Uploading script error: cannot import other scripts

Postby tom_deschamps » Tue Jul 30, 2013 1:12 am

Hi

I am trying to upload a script to omero through Insight.
I get an error because this script is importing another script of mine.
Even though this second script is accessible through PYTHONPATH, during upload I will get the following error:
Code: Select all
java.lang.Exception: org.openmicroscopy.shoola.env.data.DSAccessException: Cannot access data.
Cannot upload the script: my_omero_script.py.
   at ....
Caused by: omero.ValidationException
    serverStackTrace = ""
    serverExceptionClass = ""
    message = "Can't find params for 1648. Stderr is in file 1649
               ---stderr---
               Traceback (most recent call last):
                 File "./script", line 30, in <module>
                   from my_homemade_script import my_routines
               ImportError: No module named my_homemade_script

Any idea how I could get this to work?
Thanks
tom_deschamps
 
Posts: 22
Joined: Fri Mar 22, 2013 12:22 am

Re: Uploading script error: cannot import other scripts

Postby jmoore » Tue Jul 30, 2013 7:18 am

How have you added my_homemade_script to the PYTHONPATH? Could you perhaps add:
Code: Select all
import sys
print sys.path

to the top of your script so we can debug what all is present?

Thanks,
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Uploading script error: cannot import other scripts

Postby tom_deschamps » Tue Jul 30, 2013 7:52 am

Hi Josh

Thanks so much for the help.
Actually the path displayed by printing the sys.path does not contain the path to my_homemade_script even though it is included in the PYTHONPATH (in the .bashrc file of the omero user account).
That means that the env variable was not read correctly when the server was started.
I'm going to look into that. That might be where my error is.
Thanks!

Tom
tom_deschamps
 
Posts: 22
Joined: Fri Mar 22, 2013 12:22 am

Re: Uploading script error: cannot import other scripts

Postby jmoore » Tue Jul 30, 2013 8:17 am

The PYTHONPATH setting in place on starting up OMERO via
Code: Select all
bin/omero admin start
should be the one in effect for the Processor. But let us know if that still doesn't work. Cheers, ~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Uploading script error: cannot import other scripts

Postby tom_deschamps » Mon Aug 19, 2013 10:41 pm

Yes, it was problem of not setting the PYTHONPATH correctly when the server was started.
Thanks
tom_deschamps
 
Posts: 22
Joined: Fri Mar 22, 2013 12:22 am


Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest