Error django is not importable in this environment pycharm

Django is not importable in this environment. (1) the first thing to illustrate the point, now on the network all kinds of copy, about today I encountered this problem, didn’t find a good way to online, and open a, then open a, completely identical copy, was no, really is too sad, to solve the problem it took me 4 to 5 hours (I am a rookie! If this article does not obtain my consent, do not reprint and plagiarism! (2) PyCharm downloaded from the Internet or copied from other computers cannot be opened directly, and some Settings need to be made, which is very annoying! Of course, the main problem is to set up the interpreter, but there are other problems, such as Django is not importable in this environment. My software version is python3.4.3 and django 2.0.7 (3) Solutions to this problem: The file – & gt; Open, find your project file (project name), as follows, my project file is under the Learn folder, which has 4 projects Then look at the following: Select open in the new window to open a new window. Select another window to close the one you are currently open. My entire project list is as follows: It doesn’t matter that my project name is not the same as zaxt_tMP12 under the project. And then: file – & gt; Settings – & gt; Project Interpreter Then, look at the picture: Hide interpreters that connect to other projects: The effect is as follows, then green + : If it’s OK, the result is like this (don’t follow it here, I’m just showing you!! : Django is not importable in this environment if you don’t grab Inherit global site-packages, you will get an error when you run. Very distressed! ?You’ve been messing with me for a long time. In fact, here’s what you should do: Then, apply – & gt; ok Django is out!! (4) Finally, add an interpreter: Select the interpreter we set up in the previous step! And run manager.py Runserver. Click Run again and you’re ready to run! It took quite a while to write the document, redid it and liked it if it helped. If this article does not obtain my consent, do not reprint and plagiarism!

Django is not importable in this environment.
(1) the first thing to illustrate the point, now on the network all kinds of copy, about today I encountered this problem, didn’t find a good way to online, and open a, then open a, completely identical copy, was no, really is too sad, to solve the problem it took me 4 to 5 hours (I am a rookie!
If this article does not obtain my consent, do not reprint and plagiarism!
(2) PyCharm downloaded from the Internet or copied from other computers cannot be opened directly, and some Settings need to be made, which is very annoying! Of course, the main problem is to set up the interpreter, but there are other problems, such as Django is not importable in this environment. My software version is python3.4.3 and django 2.0.7
(3) Solutions to this problem:
The file – & gt; Open, find your project file (project name), as follows, my project file is under the Learn folder, which has 4 projects

Then look at the following:
Select open in the new window to open a new window. Select another window to close the one you are currently open.

My entire project list is as follows:

It doesn’t matter that my project name is not the same as zaxt_tMP12 under the project.
And then: file – & gt; Settings – & gt; Project Interpreter

Then, look at the picture:

Hide interpreters that connect to other projects:

The effect is as follows, then green + :

If it’s OK, the result is like this (don’t follow it here, I’m just showing you!! :

Django is not importable in this environment if you don’t grab Inherit global site-packages, you will get an error when you run.



Very distressed! ?You’ve been messing with me for a long time. In fact, here’s what you should do:

Then, apply – & gt; ok

Django is out!!
(4) Finally, add an interpreter:

Select the interpreter we set up in the previous step! And run manager.py Runserver. Click Run again and you’re ready to run!

It took quite a while to write the document, redid it and liked it if it helped.
If this article does not obtain my consent, do not reprint and plagiarism!

Read More:

Yet another case, where my virtualenv did have Django installed, but Pycharm would still display this error.

I eventually found out that the same virtualenv path had been duplicated in the list of available interpreters. Removing all of them and re-adding fixed it.

The duplication happened after I copied the .idea from another machine, and re-created the virtualenv from Pycharm although it was already listed as a (broken) interpreter.

For people having selected a virtualenv/interpreter that HAS Django installed (but it might have changed python version since first selection…), and even re-installed Django, and still get this message, and slowly getting crazy:

File > Invalidate Caches / Restart ...

Also, keeping the list of available interpreters clean and correct always helps (on my linux, old interpreters of previous linux installations kept popping up…whaat), as well as not using special characters in virtualenv names (as was the OPs problem…see his answer). Messing with the .idea folder also is not recommended (dont copy it to your new computer ;-).

In my case I had to go to Settings (Alt+F7, or the Spanner/Cog icon) and select a Python interpreter which has Django installed alongside it.

If Django isn’t already installed, you should be able to install it via the + (plus) icon (not shown below) once an interpreter has been selected.

enter image description here

Project interpreter, which is being used in the pycharm setting , doesn’t have the django package installed. So go to

setting->Project->project interpreter

Then install django package

it will work :)

For people having selected a virtualenv/interpreter that HAS Django installed (but it might have changed python version since first selection…), and even re-installed Django, and still get this message, and slowly getting crazy: Hit File > Invalidate Caches / Restart ....

This solved it for me.

Also, keeping the list of available interpreters clean and correct always helps (on my linux, old interpreters of previous linux installations kept popping up…whaat), as well as not using special characters in virtualenv names (as was the OPs problem…see his answer).


Я получаю следующие ошибки в Pycharm.

ошибка: Django не импортируется в этой среде

он работал хорошо, но я переместил проект и virtualenv в другой каталог, и появилась ошибка. Это странно, потому что если я запускаю проект, игнорируя предупреждение о настройках конфигурации, которое я получаю, работает нормально.

проблема в том, что теперь Pycharm не находит interperter проекта.

команда, которая Pycharm работает:

/Users/plorenzo/../gestorSchools/venv/bin/python3.4 /Users/plorenzo/../gestorSchools/schoolsManager/manage.py runserver 8000

активирован virtualenv.

мой путь-это:

/Users/plorenzo/../gestorSchools/venv/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

и мой $ PYTHONPATH:

/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4

Я потратил несколько дней, пытаясь найти решение, но не смог его найти.

11 ответов


в моем случае я должен был перейти к настройкам (Alt+F7 или значок гаечного ключа/винтика) и выбрать интерпретатор Python, рядом с которым установлен Django.

Если Django еще не установлен, вы сможете установить его через зеленый значок + (не показан ниже) После выбора интерпретатора.

enter image description here


Я, наконец, нашел ошибку. Проблема заключалась в том, что одно имя папки в пути virtualenv имело акцент.

Это старый путь:

/Users/plorenzo/../telefónica/gestorSchools/venv

Это новый, который работает:

/Users/plorenzo/../telefonica/gestorSchools/venv

интерпретатор проекта, который используется в pycharm настройки , не имеет django пакет установлен. Так что иди в

setting->Project->project interpreter

установить django пакета

он будет работать :)


Это может показаться очевидным, но попробуйте выйти, а затем повторно запустить приложение PyCharm. Когда у меня была эта проблема, я продолжал получать ошибку «Django не импортируется в этой среде», даже если путь интерпретатора проекта был правильным. Ничего не работало, пока я не закрыл и снова не открыл приложение. Надеюсь, это сэкономит кому-то время.


еще один случай, когда у моего virtualenv был установлен Django, но Pycharm все равно отобразит эту ошибку.

в конце концов я узнал, что тот же путь virtualenv был дублирован в списке доступных интерпретаторов. Удаление всех из них и повторное добавление исправлено.

дублирование произошло после того, как я скопировал .идея с другой машины и воссоздала virtualenv из Pycharm, хотя она уже была указана как (сломанный) интерпретатор.


Я получил ту же проблему в OS X, и чтобы исправить это, мне пришлось использовать абсолютный путь для интерпретатора проекта

/ пользователи / я / проекты/… ОК
~/Проекты./.. не работает


Как все говорят ,чек переводчик
Был ли он правильно настроен или нет.Если вы создали свой проект в виртуальная среда, убедитесь, что вы настроили правильный интерпретатор python или нет .Интерпретатор python (Весь) и интерпретатор python(только для одного проекта с использованием virtualenv) отличаются .

Если вы используете PyCharm
Перейти к настройка->проект -> переводчик и выбрать правильный переводчик
Как только вы сделано с этим, запустите проект, если он работает, все готово .если не проверить для редактирования конфигураций и проверьте еще раз для интерпретатораenter image description here


У меня была аналогичная проблема…

Я иду PyCharm — > Preferences и попытался прочитать Django для пакетов интерпретатора проекта. PyCharm внезапно добавил Все в требования.txt-файл. И теперь я могу запустить проект без каких-либо проблем.


в моем случае я запускал Cygwin-версию Python, когда возникла эта ошибка. Исправление этого включало просто добавление некоторых путей bin cygwin в переменную Path окна.

выполнить » управление sysdm.капрал»
Перейдите на вкладку «Дополнительно»
Нажмите кнопку «Переменные среды» в нижней части этой вкладки
Найти «путь» в разделе » системные переменные»
Добавить к нему
;c:/cygwin/bin;c:/cygwin/sbin;c:/cygwin/usr/local/bin

Я не включил /usr/bin, так как по какой-то причине он объединяется в каталог /bin при просмотре в окна.


ок, в моем случае решение было:

  1. установить django
  2. используйте предложение @cbueche для удаления ~
  3. переключитесь на venv другого проекта и переключитесь обратно на мой venv для этого проекта

Я вышел и перезагрузил проект несколько раз, так что это также может быть необходимо. Я люблю PyCharm, но начинать новый проект всегда больно.


для этого вам нужно отредактировать конфигурацию проекта.
Environemt — >переменные среды устанавливают varable DJANGO_SETTINGS_MODULE=имя_проекта.настройки


Понравилась статья? Поделить с друзьями:
  • Error division by zero postgresql
  • Error displaying widget model not found kaggle
  • Error displaying widget model not found catboost
  • Error displaying the error page joomla 3
  • Error displaying the error page application instantiation error failed to start the session