2013-08-14 2 views
1

일을 걷어차 기 위해, 이것은 모두 오늘까지 완벽하게 작동했습니다. 내가 python manage.py runserver 오늘 실행하면Django Import Error - Python에서 장고가 설치된 위치를 어떻게 알 수 있습니까?

, 그것은 파고를 많이 후

Traceback (most recent call last): 
    File "manage.py", line 8, in <module> 
    from django.core.management import execute_from_command_line 
ImportError: No module named django.core.management 

말, 오류가 침을 뱉고, 내 장고가 (pip install django가 넣어 곳이야) /usr/local/lib/python2.7/site-packages/에 설치되어 있는지 찾았지만, 파이썬은 지금이었다 그것에서 찾고 /Library/Python/2.7/site-packages

위의 디렉토리에 장고가 설치되었다는 것을 파이썬에게 어떻게 알릴 수 있습니까?

참고로,이 내 sys.path에

['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib- 
scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', 
'/Library/Python/2.7/site-packages'] 
+0

'sys.path'에'/ usr/local/lib/python2.7/site-packages'를 추가하십시오. –

+0

터미널에서 파이썬 유휴를 실행하고 django.core.management에서 입력하면 어떻게됩니까? import execute_from_command_line – amb1s1

+0

@ amb1s1 Django라는 모듈이 없다고 말합니다. – warchinal

답변

2

당신은 그 다음의 .bash_profile 파일에이 줄을 추가 터미널

sudo vi ~/.bash_profile 

에서 다음을 수행하여 파이썬 경로에 경로를 추가 할 수있다

export PYTHONPATH=/usr/local/lib/python2.7/site-packages/ 

터미널을 종료하고 다시 엽니 다. 이제 너는 잘되어야한다.

+0

감사합니다. 나는 아직도 $ PYTHONPATH에서 설치 디렉토리가 사라진 이유를 모른다. – warchinal

1

이런 식으로 시도 할 수있다.

sudo vi ~/.bash_profile 
export PYTHONSTARTUP=/usr/local/lib/python2.7/site-packages/ 

and modify sys.path at runtime with this 

import sys 
sys.path.insert(0, '/usr/local/lib/python2.7/site-packages') 
that could be necessary later for your apache and .wsgi files. 
관련 문제