code

Django- "django.core.management라는 모듈 없음"

codestyles 2020. 8. 25. 08:04
반응형

Django- "django.core.management라는 모듈 없음"


명령 줄에서 Django를 실행하려고하면 다음 오류가 발생합니다.

File manage.py, line 8, in <module>
     from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

이 문제를 해결하는 방법에 대한 아이디어가 있습니까?


장고가 설치되어 있지 않은 것 같습니다. 다음 명령으로 생성 된 디렉토리를 확인해야합니다.

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

거기에 django 패키지가 있는지 확인하십시오.

사이트 패키지 내부에 django 폴더가 없으면 django가 설치되어 있지 않은 것입니다 (적어도 해당 버전의 파이썬에서는).

두 개 이상의 Python 버전이 설치되어 있고 django가 다른 버전 내에있을 수 있습니다. 입력 python하고 TAB을 누르면 모든 버전의 파이썬을 찾을 수 있습니다 . 여기 내가 가진 모든 다른 파이썬이 있습니다.

$python
python            python2-config    python2.6         python2.7-config  pythonw2.5
python-config     python2.5         python2.6-config  pythonw           pythonw2.6
python2           python2.5-config  python2.7         pythonw2          pythonw2.7

각 파이썬 버전에 대해 위의 명령을 수행하고 각 버전의 site-packages 디렉토리를 살펴보고 django가 설치되어 있는지 확인할 수 있습니다. 예를 들면 :

python2.5 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
python2.6 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

python2.6 내에서 django를 발견하면 원래 명령을 시도하십시오.

python2.6 manage.py ...

sudo pip install django --upgrade 

나를 위해 트릭을했다.


같은 오류가 발생하여 다음과 같이 수정했습니다.

다음 명령을 사용하여 가상 환경을 활성화해야했습니다.

source python2.7/bin/activate

아마도 manage.py첫 번째 줄에서 시작 !/usr/bin/python하는 것은 가상 환경에서가 아닌 시스템 전역 파이썬을 사용하고 있음을 의미합니다.

그래서 교체

/usr/bin/python

~/projectpath/venv/bin/python

그리고 당신은 잘해야합니다.


글쎄요, 오늘 virtualenv와 django를 설치 한 후 같은 오류가 발생했습니다. 나에게는 내가 (사용 sudo는 있다고했다 sudo는 PIP 장고 설치 장고를 설치), 그리고 나는 실행하려고했다 manage.py의 runserver을 하지 않고 sudo는 . 방금 sudo를 추가했고 작동했습니다. :)


가상 래퍼와 함께 가상 환경을 사용하고 있습니까? Mac을 사용하십니까?

그렇다면 이것을 시도하십시오.

명령 줄에 다음을 입력하여 가상 환경을 시작한 다음 작업합니다.

1.)

source virtualenvwrapper.sh

또는

source /usr/local/bin/virtualenvwrapper.sh

2.)

workon [environment name]

참고 (초보자로부터)-환경 이름을 괄호로 묶지 마십시오.


This problem occurs when django is not installed on your computer. When django is not installed which means django.core.management module is also is not installed. So it didn't find this module and it gives error.
For solving this problem we should install django using pip. Open comand line cmd(on windows) and type as

pip install django

This command will install django in your computer. If you don't have install pip. you should install pip. Here how to install pip on windows


I am having the same problem while running the command-

python manage.py startapp < app_name >

but problem with me is that i was running that command out of virtual environment.So just activate your virtual environment first and run the command again -


Okay so it goes like this:

You have created a virtual environment and django module belongs to that environment only.Since virtualenv isolates itself from everything else,hence you are seeing this.

go through this for further assistance:

http://www.swegler.com/becky/blog/2011/08/27/python-django-mysql-on-windows-7-part-i-getting-started/

1.You can switch to the directory where your virtual environment is stored and then run the django module.

2.Alternatively you can install django globally to your python->site-packages by either running pip or easy_install

Command using pip: pip install django

then do this:

import django print (django.get_version()) (depending on which version of python you use.This for python 3+ series)

and then you can run this: python manage.py runserver and check on your web browser by typing :localhost:8000 and you should see django powered page.

Hope this helps.


I experience the same thing and this is what I do.

First my installation of

pip install -r requirements.txt

is not on my active environment. So I did is activate my environment then run again the

pip install -r requirements.txt


In case this is helpful to others... I had this issue because my virtualenv defaulted to python2.7 and I was calling Django using Python3 while using Ubuntu.

to check which python my virtualenv was using:

$ which python3
>> /usr/bin/python3

created new virtualenv with python3 specified (using virtualenv wrapper https://virtualenvwrapper.readthedocs.org/en/latest/):

$ mkvirtualenv --python=/usr/bin/python3 ENV_NAME

the python path should now point to the virtualenv python:

$ which python3
>> /home/user/.virtualenvs/ENV_NAME/bin/python3

This also happens if you change the directory structure of your python project (I did this, and then puzzled over the change in behavior). If you do so, you'll need to change a line in your /bin/activate file. So, say your project was at

/User/me/CodeProjects/coolApp/

and your activate file is at

/User/me/CodeProjects/coolApp/venv/bin/activate

when you set up your project, then you changed your project to

/User/me/CodeProjects/v1-coolApp/

or something. You would then need to open

/User/me/CodeProjects/v1-coolApp/venv/bin/activate

find the line where it says

VIRTUAL_ENV="/User/me/CodeProjects/coolApp"
export VIRTUAL_ENV

and change it to

VIRTUAL_ENV="/User/me/CodeProjects/v1-coolApp"

before reactivating


In my case, I am using Ubuntu. The problem can be that I don't have the permission to write to that folder as a normal user. You can simply add the sudo before your command and it should work perfectly. In my case sudo python manage.py syncdb.


I had the same issue and the reason I was getting this message was because I was doing "manage.py runserver" whereas doing "python manage.py runserver" fixed it.


I had the same problem and following worked good, you should navigate main folder in your project than type:

source bin/activate 

had the same problem.run command 'python manage.py migrate' as root. works fine with root access (sudo python manage.py migrate )


My case I used pyCharm 5 on mac. I also had this problem and after running this command my problem was solved

sudo pip install django --upgrade 

You can try it like so : python3 manage.py migrate (make sur to be in the src/ directory)

You can also try with pip install -r requirements.txt (make sur you see the requirements.txt file when you type ls after the migrate

If after all it still won't work try pip install django

Hope it helps


You must choose your Project first before running the server , type this workon your_project_name then python manage.py runserver


File and Directory ownership conflict will cause issues here. Make sure the ownership of the directories and files under the project are to the current user. (You can change them using the chown command with the -R option.) Try rerunning the command: this solved the problem for me when running through the "First Django App" sample:

python manage.py startapp polls

I got the same problem trying to use the python manage.py runserver. In my case I just use sudo su. Use the terminal as a root and try it again an it works partially. So I use python manage.py migrate comand and it fix it.

참고URL : https://stackoverflow.com/questions/14013728/django-no-module-named-django-core-management

반응형