add project directory path to python path permanently

634 views
Skip to first unread message

Nikhil Verma

unread,
Dec 1, 2011, 5:59:15 AM12/1/11
to django...@googlegroups.com

Hi all,

I want to add my django project directory path to PYTHONPATH. I am a newbie in ubuntu 11.10
Please tell me step by step. When i do
>>>import sys
>>>sys.path.append(''project_directory path")
It does append but not permanently. I want it like whenever i do sys.path it should show me Project Directory path in PYTHONPATH
--
Regards
Nikhil Verma
+91-958-273-3156

Daniel Roseman

unread,
Dec 1, 2011, 6:13:24 AM12/1/11
to django...@googlegroups.com
Why? If you start your shell with `./manage.py shell` you will always have this.
--
DR. 

Nan

unread,
Dec 1, 2011, 11:47:25 AM12/1/11
to Django users

Do you have pip installed? If so, you can just create a setup.py
script [1] and from inside your project directory run:

pip install -e ./

I assume setuptools (easy_install) can do the same, but I'm not 100%
clear on the command.

[1] http://docs.python.org/distutils/setupscript.html

DrBloodmoney

unread,
Dec 1, 2011, 1:21:09 PM12/1/11
to django...@googlegroups.com
On Thu, Dec 1, 2011 at 5:59 AM, Nikhil Verma <varma.n...@gmail.com> wrote:
>
> Hi all,
>
> I want to add my django project directory path to PYTHONPATH. I am a newbie
> in ubuntu 11.10
> Please tell me step by step. When i do
>>>>import sys
>>>>sys.path.append(''project_directory path")
> It does append but not permanently. I want it like whenever i do sys.path it
> should show me Project Directory path in PYTHONPATH

The easiest way is to find out where your site-packages is on your
python installation. Then just symlink your django project directory
there.

Or just use a separate virtualenv for every django project (hint: this
is what you should be doing anyways). Then just symlink into your
virtualenv site-packages

Reply all
Reply to author
Forward
0 new messages