WebFaction
Community site: login faq

Hello,

I have a Django app set up, let's say ~/webapps/myapp.

If I am inside the app folder or any subfolder, sys.path automatically includes '~/webapps/myapp/lib/python2.7'. This means that from the app folder I can run bin/django-admin.py just fine because it knows where to find the django package.

However, I moved the actual project files into an SVN repository whose working copy is ~/svn_wc/myapp/trunk. When I run python from this directory, it doesn't include the app in sys.path anymore (which makes sense...) so I can't use the django package anymore from manage.py

I know how to manually add the path/fix it so that manage.py works from inside the working copy, but I'm really confused how python is getting that extra sys.path entry when I'm inside the django app to begin with. Any subdirectory has access, even ~/webapps/myapp/apache2/logs or something -- it knows to go up to the app root and append /lib/python2.7 @_@ I'm just running python from the command line, not through apache or anything.

Can someone explain how this works?

Thanks!

asked 17 May '11, 15:31

tyler
312
accept rate: 0%


That's some convenience magic that we implement via sitecustomize.py - if you want to see how it works, feel free to look at the webapp_path_modifications function in /usr/local/lib/python2.7/sitecustomize.py on your server.

Hope that helps!

permanent link

answered 17 May '11, 15:38

seanf
12.2k41836
accept rate: 37%

Thanks! Very helpful :)

(17 May '11, 15:48) tyler
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×337
×4

question asked: 17 May '11, 15:31

question was seen: 3,966 times

last updated: 17 May '11, 15:48

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM