When i try create new project on Django. 'Error creating Django application'

已回答

When i try create new project on Django i see this error
Django 1.6.7
pip 9.0.1
stuptools 29.8.0
python 3.6.0
Windows 7 x64




Error creating Django application: Error on python side. Exit code: 1, err: Traceback (most recent call last):
File "D:\PyCharm 2016.3.2\helpers\pycharm\_jb_django_project_creator.py", line 12, in <module>
management.execute_from_command_line(argv=["django-admin", "startproject", project_name, path])
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
utility.execute()
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\core\management\__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\core\management\__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Program Files (x86)\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\core\management\commands\startproject.py", line 2, in <module>
from django.core.management.templates import TemplateCommand
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\core\management\templates.py", line 16, in <module>
from django.template import Template, Context
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\template\__init__.py", line 53, in <module>
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\template\base.py", line 19, in <module>
from django.utils.html import escape
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\utils\html.py", line 14, in <module>
from .html_parser import HTMLParser, HTMLParseError
File "C:\Users\Ninja\AppData\Roaming\Python\Python36\site-packages\django\utils\html_parser.py", line 12, in <module>
HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
out:


0

You are using Python 3.6 and an old Django, thus you're hit with this issue. Upgrade your Django or downgrade your Python.

1
Avatar
Permanently deleted user

Thx. Now its work

0

Please I'am running in almost same issue, previously I was creating django projects in Pycharm Professional without problems, but know every new django project I try to create I encounter this problemAnd Honestly nothing I tried works so far to solve it.

0
Could you please try the following? 

1. Add the following lines to **Help | Diagnostic Tools | Debug Log Settings...**:

```
#com.intellij.execution.configurations.GeneralCommandLine
```

(keep the # character)

2. Reproduce the issue and collect logs from **Help | Collect Logs and Diagnostic Data**.

3. Upload the logs to https://uploads.jetbrains.com and provide the ID in your reply.
1

Ok, here's the upload Id 2023_06_17_tei85i4wkim3AT5hkjvA3d and thank you for the help.

0
 Thank you, but there doesn't seem to be a command line debug information. Did you add the debug option I mentioned?
0

Yes I did. Well what about now. Upload id: 2023_06_20_E8kiAVaZ9oK5y1tKSXYrSj  and thank you.

0
Thank you,

I'll ask a few questions to narrow down the issue if you don't mind. Are you creating a new project with a new python environment? What type of environment are you using (venv, pipenv, poetry, conda)?
0

I am creating new environment using venv.

 

0
Ok, so it seems that the packaging tool can't install Django into this environment for some reason. I suggest trying this manually and seeing if you get any errors.

Please try the following:

1. While in terminal, activate the venv that PyCharm has created

2. Run the following script to install Django

```
C:\Users\Rida\Desktop\djangoProject\venv\Scripts\python.exe "C:/Program Files/JetBrains/PyCharm 2023.1.2/plugins/python/helpers/packaging_tool.py" install django
```

3. Check if Django was installed with `pip list`

Is it successful?
0

Yes it is downloaded but the default structure created previously is not anymore.

0
Does it work if you try creating a new Django project in PyCharm after installing Django manually as I mentioned in the previous comment? 

If not, please provide the command that you used to install Django, and a new log from PyCharm.
1

No the issue is still the same, here's the new log from Pycharm 2023_07_11_zTCAGi1UAGikmo5vnBLUXw

0

Please try this from the terminal:

> mkdir -p path/to/project
> cd path/to/project
> python3 -m venv venv
> source venv/bin/activate
> pip install django
> django-admin startproject foo .
> python -c "import django"

If everything works correctly, please try opening the project in PyCharm and enable Django support in **Preferences | Languages & Frameworks | Django**.

0

I finally solved the problem!

I am leaving this for anyone who encountered the same problem as me. I noticed beside this main problem that I had another one too which is tracked here and ironically the solution was provided by @kal in this stack overflow post which consists of deleting Pycharm and ALL configuartion files, one hint though for Windows Users, to find the configuration files use "CTRL + R" then enter the path mentioned in solution, and good luck.

0

请先登录再写评论。