Menu ▾ ▴

Difference between Pydev & Python stand alone

2009-03-28
2013-03-15
  • Diederik van Liere

    Hi,
    I am not sure if someone else has noticed (and maybe i have made weird changes to Pydev) but it seems that there are sometimes subtle differences between Python code executed in Eclipse / Pydev and Python stand alone. I noticed two different behaviors:
    1) the call to os.environ["PATH"] creates a different path when running Pydev in Eclipse on OSX then running it stand alone in Python on OSX. In Pydev it seems that the path is missing the directories that are added to the personal shell profiles.

    2) When parsing ASCII files, Pydev handles non-standard ASCII characters without throwing an error, even without using string = string.decode('utf-8') while the same code will throw an error when running stand alone on the same set of files. (This happens on a Windows machine)

    The second case is not so much of a problem, it makes life a little bit easier because the code is suddenly a little bit more robust, the first problem caused some real headache to figure out why python wouldn't launch an external program from within pydev. My question is basically this: is this intended behavior of Pydev?
    Thanks a lot for Pydev, it has improved my productivity significantly!!
    best,
    Diederik

     
    • Fabio Zadrozny

      Fabio Zadrozny - 2009-03-29

      1. Well, Pydev should inherit the PATH from the shell that started Eclipse unless you changed it in the interpreter configuration or in the launch configuration (if none of those are changed and you still have problems, it might be related to something in Mac OSX, but I'd have to dig deeper to see why it was different in Mac OSX -- it could be that that's a Mac limitation, or maybe you have to start Eclipse from a console shell to have it -- not really sure as I don't use Mac that much).

      2. This is because Pydev will provide a custom sitecustomize.py to properly configure the encoding for the shell (and it's usually UTF-8 or some other that supports unicode -- diferrent from the command shell that'll only support ASCII).

      Cheers,

      Fabio

       
    • Diederik van Liere

      Hi Fabio
      I don't remember doing anything weird to my configuration of pydev or python. this is what happens when I call the path in the python prompt:

      import os
      p = os.environ["PATH"]
      then p has as value:
      /Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/
      bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/
      sbin:/usr/local/bin:/usr/X11/bin

      and when i run the exact same code in pydev /eclipse i have this as a result:
      /usr/bin:/bin:/usr/sbin:/sbin

      Best,
      diederik

       
      • Fabio Zadrozny

        Fabio Zadrozny - 2009-04-01

        Have you tried running Eclipse from a shell (the same shell you use to run python)?

        Cheers,

        Fabio

         
    • Diederik van Liere

      I'll give it a try and let you know.
      best,
      Diederik

       
  • nadava

    nadava - 2010-05-06

    Hi Fabio,

    I ran into the same problem and found this thread from a year ago.
    Trying to run pygraphviz through Eclipse and pydev, and it is not working because /user/local/bin is not in the environment path, while when I run it from the shell runs perfectly.

    Using Mac OS, Leopard 10.5

    I realized this difference through this thread on the pygraphviz forum (http://groups.google.com/group/pygraphviz-discuss/browse_thread/thread/160ca93c5cb56cd1/ba3a873cfc65759f?show_docid=ba3a873cfc65759f)

    Is there any way to manually add this path to the pydev configuration so that it will be added to the environment path?

    Thank you!
    Nadav

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2010-05-06

    You can specify the PATH environment variable in the interpreter (there's an environment tab there). Or you may do that in the run configuration for only that configuration.

    But note that in both cases it will replace the whole path.

    The solution I usually use is starting eclipse from a shell that's already configured properly (although this is on windows, but I guess in Mac OS it should also work).

    Cheers,

    Fabio