[IronPython] How come I cant import time or threading in IronPython

Dino Viehland dinov at microsoft.com
Wed Mar 18 17:12:14 CET 2009


Do you have IronPython.Modules.dll next to IronPython.dll?  IronPython.Modules.dll contains the implementation of thread.

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Jonatan Nilsson
> Sent: Wednesday, March 18, 2009 9:08 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] How come I cant import time or threading in
> IronPython
> 
> Thank you for your quick response.
> 
> I tried doing what you asked me.
> I added the following to the engine code:
> 
> ---------------------------
> ScriptEngine engine = Python.CreateEngine();
> engine.SetSearchPaths(new string[] { "C:\\Program
> Files\\IronPython-2.0.1\\Lib\\", "C:\\Python25\\Lib\\" });
> ---------------------------
> 
> When I run the following python code:
> 
> ---------------------------
> import sys
> print(sys.path)
> import threading
> ---------------------------
> 
> It prints out:
> ['C:\\Program Files\\IronPython-2.0.1\\Lib\\', 'C:\\Python25\\Lib\\']
> 
> Still it crashes with the same message:
> "No module named thread"
> 
> When I go into the "C:\Program Files\IronPython-2.0.1\Lib\threading.py"
> I find the following:
> ---------------------------
> try:
>     import thread
> except ImportError:
>     del _sys.modules[__name__]
>     raise
> ---------------------------
> 
> I am wondering that maybe it is not finding "thread" because I am using
> C# and the "thread" is a C library...
> 
> Also when I try to run "import time" it also complains that module time
> doesn't exist. This is true cause there is no time.py in the Lib
> folder.
> Maybe I have a faulty install or not the complete Python installed in
> my
> computer?
> 
> 
> Sincerely:
> Jonatan Nilsson
> Iceland
> 
> 
> Michael Foord wrote:
> > These libraries you are attempting to import are Python standard
> > library modules. To import them you must have the Python standard
> > library available - and on sys.path for the engine being used to do
> > the imports.
> >
> > You set sys.path programattically using engine.SetSearchPaths (?)
> > passing in an array of strings.
> >
> > All the best,
> >
> > Michael Foord
> >
> > BlackMan890 wrote:
> >> Hi there.
> >>
> >> this has probably been answered before but I cant seem to find the
> >> answer.
> >> When I run "import time" in python through IronPython using C#, an
> >> exception
> >> occurs with the message: "no module named time".
> >> The same thing happens when I run "import threading" except with a
> >> different
> >> exception: "No module named thread"
> >>
> >> Why am I encountering there problems?
> >>
> >>
> >> Sincerely:
> >> Jonatan Nilsson
> >> Iceland
> >>
> >>
> >>
> >
> >
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list