2
import sys
print(sys.path)

'C:\\python32\\Lib\\site-packages\\django'
'C:\\Python32'
'C:\\Python32\\lib\\site-packages'
...

for some reason, my pythonpath got messy. I'd like to organize it. Is it correct that I don't need the first and the last one above? And how can I change it permanently? (Not like sys.path.remove or sys.path.append)

I'm using Python3.2. in windows8.

user1610952
  • 1,249
  • 1
  • 16
  • 31

1 Answers1

1

Path 'C:\Python32\lib\site-packages' is added to sys.path by the built-in site module.

If you want to, you can start python with the -S flag to tell the site module "Don't add site-packages".

python -S

Next, 'C:\python32\Lib\site-packages\django'.
Here's a wild guess: you installed django with pip/easy_install/msi-installer and there is a file C:\python32\Lib\site-packages\django.pth (or something like this ending with .pth)

Quoting the docs:

A path configuration file is a file whose name has the form name.pth and exists in one of the four directories mentioned above; its contents are additional items (one per line) to be added to sys.path.

You can remove django.pth file (not recommended, see below) to remove '..../django' from sys.path

So, short answer: don't mess with sys.path, what's in sys.path is probably for a good reason. If you don't need django, then uninstall django using whatever tool you used to install it. Same for every package you don't need.

Nigel Tufnel
  • 11,146
  • 4
  • 35
  • 31