Re: Python import search path

2011-08-20 Thread Chris Angelico
On Sat, Aug 20, 2011 at 10:52 AM, Kevin Zhang wrote: > Found a few solution in python docs. > A. sys.path.append > I think A is not so pretty, and I don't have root  privilege to use B and C. > So any both more elegant and practical solutions? If, as I understand from your directory tree, ttt.py

Python import search path

2011-08-20 Thread Kevin Zhang
Hi, This is the directory tree. project └── sme ├── src │ ├── a.pth │ ├── sss.py └── test └── ttt.py I need to import sss.py in ttt.py. Found a few solution in python docs. A. sys.path.append B. add ***.pth file C. edit .../site-packages/site.py I found out that a.pt

Re: module import search path strangeness

2008-08-12 Thread Peter Otten
Sion Arrowsmith wrote: > Peter Otten <[EMAIL PROTECTED]> wrote: >>tow wrote: >>> sys.path.append(os.path.join(project_directory, os.pardir)) >>> project_module = __import__(project_name, {}, {}, ['']) >>> sys.path.pop() >>Ouch. > > I presume that "Ouch" is in consideration of what mi

Re: module import search path strangeness

2008-08-12 Thread tow
On Aug 12, 4:59 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > tow wrote: > > On Aug 12, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: > >> tow wrote: > > >> > Basically, I had thought that import and imp.find_module used exactly > >> > the same > >> > search path, but the above example shows that

Re: module import search path strangeness

2008-08-12 Thread Sion Arrowsmith
Peter Otten <[EMAIL PROTECTED]> wrote: >tow wrote: >> sys.path.append(os.path.join(project_directory, os.pardir)) >> project_module = __import__(project_name, {}, {}, ['']) >> sys.path.pop() >Ouch. I presume that "Ouch" is in consideration of what might happen if the subject of the __

Re: module import search path strangeness

2008-08-12 Thread Peter Otten
tow wrote: > On Aug 12, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: >> tow wrote: > >> > Basically, I had thought that import and imp.find_module used exactly >> > the same >> > search path, but the above example shows that at least in this >> > circumstance they >> > don't; import is picking

Re: module import search path strangeness

2008-08-12 Thread tow
On Aug 12, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: > tow wrote: > > Basically, I had thought that import and imp.find_module used exactly > > the same > > search path, but the above example shows that at least in this > > circumstance they > > don't; import is picking up additional search

Re: module import search path strangeness

2008-08-12 Thread Peter Otten
tow wrote: >>> > I have a python script (part of a django application, if it makes any >> > difference) which is exhibiting the following behaviour: >> >> > import my_module # succeeds >> > imp.find_module("my_module") # fails, raising ImportError >> >> > which is completely baffling me. According

Re: module import search path strangeness

2008-08-12 Thread tow
On Aug 12, 4:59 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 11 Aug 2008 19:19:19 -0300, tow <[EMAIL PROTECTED]>   > escribi : > > > I have a python script (part of a django application, if it makes any > > difference) which is exhibiting the following behaviour: > > > import my_mod

Re: module import search path strangeness

2008-08-11 Thread Gabriel Genellina
En Mon, 11 Aug 2008 19:19:19 -0300, tow <[EMAIL PROTECTED]> escribi�: I have a python script (part of a django application, if it makes any difference) which is exhibiting the following behaviour: import my_module # succeeds imp.find_module("my_module") # fails, raising ImportError which is

module import search path strangeness

2008-08-11 Thread tow
I have a python script (part of a django application, if it makes any difference) which is exhibiting the following behaviour: import my_module # succeeds imp.find_module("my_module") # fails, raising ImportError which is completely baffling me. According to sys.path, both should fail; the direct

Re: Python import search path!

2007-12-14 Thread Bjoern Schliessmann
SMALLp wrote: > remember worked file when i wrote eg. import myFile but now in > Ubuntu it says Module not found. (I'm using Ubuntu and I've > installed python 2.5 and wxPython 2.8.4, and I'm using GedIt as my > favorite text editor). The question is how to make this work > (files are in the same

Re: Python import search path!

2007-12-14 Thread SMALLp
[EMAIL PROTECTED] wrote: > On Dec 14, 3:44 pm, SMALLp <[EMAIL PROTECTED]> wrote: >> Hy! >> I'm new in Linux, and i feel little less newer in python. >> >> I need advice and help. I'm making an application witch purpose is >> irrelevant. It has a lot of code for now and I've only made interface. >>

Re: Python import search path!

2007-12-14 Thread kyosohma
On Dec 14, 3:44 pm, SMALLp <[EMAIL PROTECTED]> wrote: > Hy! > I'm new in Linux, and i feel little less newer in python. > > I need advice and help. I'm making an application witch purpose is > irrelevant. It has a lot of code for now and I've only made interface. > So I've tried to split code into

Python import search path!

2007-12-14 Thread SMALLp
Hy! I'm new in Linux, and i feel little less newer in python. I need advice and help. I'm making an application witch purpose is irrelevant. It has a lot of code for now and I've only made interface. So I've tried to split code into separate files and in windows as I remember worked file when i

Re: jython import search path

2007-02-23 Thread Diez B. Roggisch
> Accepted strategy? It doesn't seem very portable. It assumes that > everyone puts their library > modules in the exact same place. Or do they just figure that changing > the sys.path.append > line is easy enough? Portability has nothing to do with it. If you arrange your project in a way that th

Re: jython import search path

2007-02-22 Thread Russ
Diez B. Roggisch wrote: > >> Maybe Jython expert has the perfect answer but til then. > >> > >> Did you try: > >> > >> sys.path.append('path to search') > >> > >> Usually this works if nothing else does. > >> > >> -Larry > > > > Thanks. That's a good workaround, but I would like to know the > > "

Re: jython import search path

2007-02-22 Thread Diez B. Roggisch
Russ wrote: > On Feb 21, 4:15 pm, Larry Bates <[EMAIL PROTECTED]> wrote: >> Russ wrote: >> > I have a Python program that I want to run in Jython so I can get Java >> > bytecode output. The program runs fine in Python, but when I change >> > the first line of the main program to make it run in Jyt

Re: jython import search path

2007-02-21 Thread Russ
On Feb 21, 4:15 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > Russ wrote: > > I have a Python program that I want to run in Jython so I can get Java > > bytecode output. The program runs fine in Python, but when I change > > the first line of the main program to make it run in Jython, it fails > > t

Re: jython import search path

2007-02-21 Thread Larry Bates
Russ wrote: > I have a Python program that I want to run in Jython so I can get Java > bytecode output. The program runs fine in Python, but when I change > the first line of the main program to make it run in Jython, it fails > to find some of the imported modules. These are just plain Python > im

jython import search path

2007-02-21 Thread Russ
I have a Python program that I want to run in Jython so I can get Java bytecode output. The program runs fine in Python, but when I change the first line of the main program to make it run in Jython, it fails to find some of the imported modules. These are just plain Python imports of code I wrote

Re: import search path

2005-06-22 Thread Scott David Daniels
Mike Meyer wrote: > "SHELTRAW, DANIEL" <[EMAIL PROTECTED]> writes: >>If a Python program has an import statement like: >>import FFT >> >>how do I determine the path to the imported file? > > guru% python > Python 2.4.1 (#2, Apr 25 2005, 21:42:44) > [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5 > Typ

Re: import search path

2005-06-22 Thread Kent Johnson
Mike Meyer wrote: > "SHELTRAW, DANIEL" <[EMAIL PROTECTED]> writes: >>If a Python program has an import statement like: >> >>import FFT >> >>how do I determine the path to the imported file? > > > guru% python > Python 2.4.1 (#2, Apr 25 2005, 21:42:44) > [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5

Re: import search path

2005-06-22 Thread Mike Meyer
"SHELTRAW, DANIEL" <[EMAIL PROTECTED]> writes: > Hello Python list > > If a Python program has an import statement like: > > import FFT > > how do I determine the path to the imported file? guru% python Python 2.4.1 (#2, Apr 25 2005, 21:42:44) [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5 Type "hel

import search path

2005-06-22 Thread SHELTRAW, DANIEL
Hello Python list If a Python program has an import statement like: import FFT how do I determine the path to the imported file? Thanks, Daniel -- http://mail.python.org/mailman/listinfo/python-list