Import Error: cannot import name

View: New views
4 Messages — Rating Filter:   Alert me  

Import Error: cannot import name

by Michael-556 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey folks, I've been trying to figure this out for the past couple of days and had no luck. I'm running the following script from Java via the PythonInterpreter (using Eclipse & Jython 2.5.1). I have added the standalone Jython jar file to my project as a library.

Running this script:
import threading
def hello():
    print "hello, world"
t = Timer(2.0, hello)
t.start()
print "hello"

Gives me the following error:

'Execution failed.  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "../lib/python/threading.py", line 6, in <module>
    import traceback
  File "../lib/python/traceback.py", line 3, in <module>
    import linecache
  File "../lib/python/linecache.py", line 9, in <module>
    import os
  File "../lib/python/os.py", line 132, in <module>
    from os.path import curdir, pardir, sep, pathsep, defpath, extsep, altsep, devnull
ImportError: cannot import name curdir'

I have no idea why I'm getting this message.

Thanks!

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Parent Message unknown Re: Import Error: cannot import name

by Michael-556 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, but the problem still persists...

josu jugo wrote:

> Hi Michael
>
> You need to change the next sentence
>
> t = threading.Timer(2.0, hello)
>
> Regards
>
> josu
>
>
> On 2009 urr 29, at 22:12, Michael wrote:
>
>> import threading
>> def hello():
>>     print "hello, world"
>> t = Timer(2.0, hello)
>> t.start()
>> print "hello"
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Parent Message unknown Re: Import Error: cannot import name

by Michael-556 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I downloaded it off the Jython.org site and select standalone
installation. I grab that .jar file, and put it in the lib folder of my
project in Eclipse (on the build path), and then try to run that script
with the python interpreter, but it always barfs. I'm running Ubuntu
8.10. The script also works fine when I run it with Jython outside of
Eclipse.

Because it seems like the error got chopped off in my posting from what
someone else said I'll post it again:

'Execution failed.  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "../lib/python/threading.py", line 6, in <module>
    import traceback
  File "../lib/python/traceback.py", line 3, in <module>
    import linecache
  File "../lib/python/linecache.py", line 9, in <module>
    import os
  File "../lib/python/os.py", line 132, in <module>
    from os.path import curdir, pardir, sep, pathsep, defpath, extsep,
altsep, devnull
ImportError: cannot import name curdir'

Daniel Baktiar wrote:

> Hi Mike,
>
> Could you elaborate more on how you get the Jython installation, and
> how do you invoke Jython?
> The script works perfectly on my Jython 2.5.0 installation.
>
> Regards,
> Daniel
>
> 2009/10/31 Michael <michaelsucci@...
> <mailto:michaelsucci@...>>
>
>     Thanks, but the problem still persists...
>
>     josu jugo wrote:
>     > Hi Michael
>     >
>     > You need to change the next sentence
>     >
>     > t = threading.Timer(2.0, hello)
>     >
>     > Regards
>     >
>     > josu
>     >
>     >
>     > On 2009 urr 29, at 22:12, Michael wrote:
>     >
>     >> import threading
>     >> def hello():
>     >>     print "hello, world"
>     >> t = Timer(2.0, hello)
>     >> t.start()
>     >> print "hello"
>     >
>
>
>     ------------------------------------------------------------------------------
>     Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>     is the only developer event you need to attend this year.
>     Jumpstart your
>     developing skills, take BlackBerry mobile applications to market
>     and stay
>     ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>     http://p.sf.net/sfu/devconference
>     _______________________________________________
>     Jython-users mailing list
>     Jython-users@...
>     <mailto:Jython-users@...>
>     https://lists.sourceforge.net/lists/listinfo/jython-users
>
>
>
>
> --
> Daniel Baktiar - JEEwish & Pythoneer
> (http://dbaktiar.wordpress.com)



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: Import Error: cannot import name

by josu jugo-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Michael

I have repeat your test in Macosx (with the last eclipse version) and  
Ubuntu 8.10 using eclipse sdk 3.2.2 and in the two cases I obtain the  
expected result.

I am using this simple program with your script


import org.python.util.PythonInterpreter;

public class Main{

         public static void main(String[] args){
         PythonInterpreter interpreter = new PythonInterpreter();
         interpreter.execfile("/home/josu/script.py");
         System.out.println("Hello");
     }

}

and the output from the shell and in eclipse is

Hello
Hello
Hello,world

regards

josu



On 2009 aza 2, at 18:45, Michael wrote:

> I downloaded it off the Jython.org site and select standalone
> installation. I grab that .jar file, and put it in the lib folder of  
> my
> project in Eclipse (on the build path), and then try to run that  
> script
> with the python interpreter, but it always barfs. I'm running Ubuntu
> 8.10. The script also works fine when I run it with Jython outside of
> Eclipse.
>
> Because it seems like the error got chopped off in my posting from  
> what
> someone else said I'll post it again:
>
> 'Execution failed.  Traceback (most recent call last):
>  File "<string>", line 1, in <module>
>  File "../lib/python/threading.py", line 6, in <module>
>    import traceback
>  File "../lib/python/traceback.py", line 3, in <module>
>    import linecache
>  File "../lib/python/linecache.py", line 9, in <module>
>    import os
>  File "../lib/python/os.py", line 132, in <module>
>    from os.path import curdir, pardir, sep, pathsep, defpath, extsep,
> altsep, devnull
> ImportError: cannot import name curdir'
>
> Daniel Baktiar wrote:
>> Hi Mike,
>>
>> Could you elaborate more on how you get the Jython installation, and
>> how do you invoke Jython?
>> The script works perfectly on my Jython 2.5.0 installation.
>>
>> Regards,
>> Daniel
>>
>> 2009/10/31 Michael <michaelsucci@...
>> <mailto:michaelsucci@...>>
>>
>>    Thanks, but the problem still persists...
>>
>>    josu jugo wrote:
>>> Hi Michael
>>>
>>> You need to change the next sentence
>>>
>>> t = threading.Timer(2.0, hello)
>>>
>>> Regards
>>>
>>> josu
>>>
>>>
>>> On 2009 urr 29, at 22:12, Michael wrote:
>>>
>>>> import threading
>>>> def hello():
>>>>    print "hello, world"
>>>> t = Timer(2.0, hello)
>>>> t.start()
>>>> print "hello"
>>>
>>
>>
>>    
>> ------------------------------------------------------------------------------
>>    Come build with us! The BlackBerry(R) Developer Conference in  
>> SF, CA
>>    is the only developer event you need to attend this year.
>>    Jumpstart your
>>    developing skills, take BlackBerry mobile applications to market
>>    and stay
>>    ahead of the curve. Join us from November 9 - 12, 2009. Register  
>> now!
>>    http://p.sf.net/sfu/devconference
>>    _______________________________________________
>>    Jython-users mailing list
>>    Jython-users@...
>>    <mailto:Jython-users@...>
>>    https://lists.sourceforge.net/lists/listinfo/jython-users
>>
>>
>>
>>
>> --
>> Daniel Baktiar - JEEwish & Pythoneer
>> (http://dbaktiar.wordpress.com)
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users