9

How can I add something to my "Pythonpath".

Where exactly are the files located, I have to change to add to my pythonpath?

What exactly do I add to my Pythonpath?

If Python calls:

/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/

But I want it to call

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

What do I need to add to make it work.

Strange is that I already used the django-admin.py for a startproject ccommand. But now it does not find it.

Is there a way to clean up my ALL my Python, Django so I can restart with a fresh version?

2 Answers 2

7
>>> import sys
>>> sys.path

sys.path is the list of search path for modules.

if you want a module to be loaded from /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages instead of /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/

you just need to make sure that site-packages search path comes before the Contents in sys.path

you can set the python path using PYTHONPATH environment variable

ex: (on a linux system)

export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages:$PYTHONPATH
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a million! If I set the PYTHONPATH by: sys.path.append("/PATH"), where is it written to? And your export PYTHONPATH code above: Where do I write it to... Thanks a lot again..
export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages:$PYTHONPATH, set this line in .bashrc file in your home folder. if you are updating sys.path, you can set that line in any python file but make sure that sys.path is executed before any import happens. specifically for django you can add sys.path.append at the top of manage.py file
-4

This tutorial will probably work for you if you want to remove an old version: http://docs.djangoproject.com/en/1.2/topics/install/#removing-old-versions-of-django

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.