[SciPy-User] should one put "." into PYTHONPATH
Robert Kern
robert.kern at gmail.com
Thu May 5 22:22:33 EDT 2011
On Thu, May 5, 2011 at 18:23, Ondrej Certik <ondrej at certik.cz> wrote:
> Hi,
>
> is it a good practice to have the following in .bashrc:
>
> export PYTHONPATH=$PYTHONPATH:.
I don't recommend it. You will get unexpected behavior and waste time
chasing down problems that don't actually exist.
> I know that Ubuntu long time ago had the "." in PYTHONPATH by default,
> and then dropped it. The reason why I want it is so that I can develop
> in the current directory, by doing things like:
>
> python examples/a.py
>
> where 'a.py' imports something from the current directory. I googled a
> bit, and found that some people recommend to use "setup.py develop"
> instead. I don't use setup.py in my project (I use cmake to mix
> Fortran and Python together). So one option for me is to always
> install it, and then import it like any other package from
> examples/a.py.
You don't need to do "python setup.py develop" every time. Nothing
actually depends on there being a setup.py. Just add a .pth file into
your site-packages listing the directory you want added. E.g. if you
have your sympy checkout in /home/ondrej/git/sympy/ you would have a
file named sympy.pth (or any other name ending in .pth) in your
site-packages directory with just the following contents (without the
triple quotes:
"""
/home/ondrej/git/sympy
"""
Then you can run /home/ondrej/git/sympy/examples/a.py however you
like, from whichever directory you like.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list