[Eric] Re: Question about imported modules and paths in Eric4

Detlev Offenbach detlev at die-offenbachs.de
Mon Dec 22 10:33:27 GMT 2008


Hi,

I just tested it over here and have to admit, that eric4 inherits the 
PYTHONPATH setting. However, it depends on where it is defined. If eric4 is 
started via a menu entry of the desktop, the variable has to be defined 
before the desktop ist started. If eric4 is started from a terminal window, 
you may define the variable just before starting eric4.

Regards,
Detlev

On Montag, 22. Dezember 2008, Robert Cheatham wrote:
> Ha ha ha!  My fault.  It's actually Kubuntu 7.*, running KDE 3.5.6.
> Thank you for your response.
>
> Yes, when running Python from the shell, the 'sys.path' variable has
> included the information in the 'PYTHONPATH' variable from the shell.
> Additionally, running the commands "os.environ['PYTHONPATH']" and
> "os.system('echo $PYTHONPATH')" outputs the correct 'PYTHONPATH'
> information.
>
> However, it appears that Eric4 creates its own environment.  The
> 'sys.path' variable does not include the 'PYTHONPATH' information from
> the shell in which Eric4 was started.  Also, while the
> "os.environ['PATH']" and "os.system( 'echo $PATH')" commands work
> properly when run from Eric4, their values are different from the
> 'PATH' variable in the original shell.  The "os.environ['PYTHONPATH']"
> and "os.system('echo $PYTHONPATH')" commands fail, indicating that the
> environment created by Eric4 is not the same as in the original shell.
>
> The above may be intentional, however I would like to be able to do
> one of the following:
>
> 1) Get Eric4 to inherit the PYTHONPATH information from the shell in
> which it is launched
>
> 2) Copy-paste the information from the PYTHONPATH variable into a
> search path in the Eric4 project.
>
> 3) Run a short script at the beginning of my programs something to the
> effect of this:
>         newPaths = os.system( "Get PYTHONPATH info from original shell" )
>         sys.path.append( newPaths )
>
> Options 1) and 3) are preferable so that all the environment info will
> be picked up automatically.
>
> If neither option is possible, I can manually insert the search paths
> using multiple "sys.path.append()" commands, but this will be a
> maintenance headache and will be tougher to convince others to move
> away from print statement debugging.  I am, of course, open to
> other/better options.
>
> Tusen takk.
> --Robert
>
> On Sun, Dec 21, 2008 at 10:38 AM, Sjujsckij Nickolaj <sterkrig at home.no> 
wrote:
> >  Hello
> > I think you should learn about modules and their paths in Python. For
> > example, I don't know what is module gto, probably it's your own one, and
> > you rely on current dir importing it... So read about PYTHONPATH and
> > inspect its value in your user shell, python and Eric shells (sys.path),
> > and remember about importing from current directory.
> >
> >> Using Eric4 v4.2.3 (r2620) on KDE 7.
> >
> >  Whoops! Could you lend me your time machine? (-:E
> >
> >> I still haven't been able to figure this out.
> >>
> >> More specifics, I'm importing a module named "gto" as such:
> >>> import gto
> >>
> >> This works fine if I run my python script from the command line.  When
> >> I debug the script in Eric4 I get the following error
> >>
> >>> The debugged program raised the exception ImportError
> >>> "No module named gto"
> >>
> >> So I'm wondering how I can get Eric4 to import the environment from
> >> the shell.  Or at least how I can specify the paths in which Eric4
> >> will look for modules.
> >>
> >> Using Eric4 v4.2.3 (r2620) on KDE 7.
> >>
> >> Thanks,
> >> Robert
> >>
> >> On Tue, Dec 16, 2008 at 4:18 PM, Robert Cheatham
> >>
> >> <robertcheatham at gmail.com> wrote:
> >>> I'm trying to use Eric4 for python debugging in Linux
> >>>
> >>> I'm having a problem with imported modules.  These modules are found
> >>> somewhere in our system's path variables (not sure where).  The project
> >>> I'm trying to debug works fine when run from the command line (and when
> >>> debugged under pdb), but Eric4 apparently doesn't pick up the
> >>> environment from the shell in which it was started, so an error is
> >>> thrown when attempting to import certain modules.
> >>>
> >>> I'm used to working on Visual Studio, so my first instinct was to just
> >>> copy the information from the path variables into the the path variable
> >>> in the Eric4 project.  I can't figure out how to do this.  Is there a
> >>> way to get Eric4 to either pick up the environment variables from the
> >>> shell or to transfer the path information so that Eric4 can use it?
> >>>
> >>> Using Eric4 v4.2.3 (r2620) on KDE 7.
> >>>
> >>>
> >>> Thank you.
> >>
> >> _______________________________________________
> >> Eric mailing list
> >> Eric at riverbankcomputing.com
> >> http://www.riverbankcomputing.com/mailman/listinfo/eric
>
> _______________________________________________
> Eric mailing list
> Eric at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/eric



-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the Eric mailing list