3đź‘Ť
âś…
Three choices.
-
Set
PYTHONPATH
environment variable to include your application’s directory. Be sure it has an__init__.py
file. -
Create a
.pth
file in site-packages to point to your application’s directory. -
Install your application in site-packages.
These are the three ways of “installing” a Python module. Read about the site module for more information.
👤S.Lott
4đź‘Ť
Try appending the path to sys.path at runtime.
import sys
sys.path.append('/path/to/myapp')
👤rubayeet
3đź‘Ť
Add this in your .bashrc
or .bash_profile
export PATH=$PATH:/path/to/django/bin
export PYTHONPATH=$PYTHONPATH:/path/to/myapp
👤Lauro Oliveira
- [Django]-Django send_mail results in Error 60, Operation Timed Out on Mac OSX
- [Django]-Can't get media files in heroku
- [Django]-Can't get nginx to serve collected static files
- [Django]-Django admin to edit foreign keys inline
- [Django]-Setting global variables with Cactus App for Mac
0đź‘Ť
import from path containing dir with module (with __init__.py
file)
example:
dm@batman:~/.local/15/lib/python2.7/site-packages $ pwd
/home/d/dm/.local/15/lib/python2.7/site-packages
dm@batman:~/.local/15/lib/python2.7/site-packages $ ls
django Django-1.5.11-py2.7.egg-info
dm@batman:~/.local/15/lib/python2.7/site-packages $ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
>>> import sys
>>> sys.path.append("/home/d/dgaloc/.local/15/lib/python2.7/site-packages")
>>> import django
>>> django.VERSION
(1, 5, 11, 'final', 0)
👤dmgl
- [Django]-Return object when aggregating grouped fields in Django
- [Django]-Decorating Instance Methods in Python
- [Django]-Import error: No module named 'Crypto' on Mac (Pycrypto is up-to-date)
- [Django]-In Django, is there an easy way to render a text field as a template, in a template?
Source:stackexchange.com