Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro ao criar projeto Djanfo

Alguém já se deparou com esse erro abaixo ao tentar criar um projeto em Django?

atualmente estou com o pyhton 2.7 e ou python 3.5 instalados em minha máquina.

$ django-admin startproject connectedin
Traceback (most recent call last):
  File "/home/fernando/.local/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/home/fernando/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/fernando/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/home/fernando/.local/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
    from django.utils.log import configure_logging
  File "/home/fernando/.local/lib/python3.5/site-packages/django/utils/log.py", line 13, in <module>
    from django.views.debug import ExceptionReporter, get_exception_reporter_filter
  File "/home/fernando/.local/lib/python3.5/site-packages/django/views/debug.py", line 10, in <module>
    from django.http import (HttpResponse, HttpResponseServerError,
  File "/home/fernando/.local/lib/python3.5/site-packages/django/http/__init__.py", line 4, in <module>
    from django.http.response import (
  File "/home/fernando/.local/lib/python3.5/site-packages/django/http/response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "/home/fernando/.local/lib/python3.5/site-packages/django/core/serializers/__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "/home/fernando/.local/lib/python3.5/site-packages/django/core/serializers/base.py", line 6, in <module>
    from django.db import models
  File "/home/fernando/.local/lib/python3.5/site-packages/django/db/models/__init__.py", line 6, in <module>
    from django.db.models.query import Q, QuerySet, Prefetch  # NOQA
  File "/home/fernando/.local/lib/python3.5/site-packages/django/db/models/query.py", line 13, in <module>
    from django.db.models.fields import AutoField, Empty
  File "/home/fernando/.local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 18, in <module>
    from django import forms
  File "/home/fernando/.local/lib/python3.5/site-packages/django/forms/__init__.py", line 6, in <module>
    from django.forms.fields import *  # NOQA
  File "/home/fernando/.local/lib/python3.5/site-packages/django/forms/fields.py", line 18, in <module>
    from django.forms.utils import from_current_timezone, to_current_timezone
  File "/home/fernando/.local/lib/python3.5/site-packages/django/forms/utils.py", line 15, in <module>
    from django.utils.html import format_html, format_html_join, escape
  File "/home/fernando/.local/lib/python3.5/site-packages/django/utils/html.py", line 16, in <module>
    from .html_parser import HTMLParser, HTMLParseError
  File "/home/fernando/.local/lib/python3.5/site-packages/django/utils/html_parser.py", line 12, in <module>
    HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
1 resposta
solução!

INFORMAÇÃO: após pesquisar sobre o erro descobri que o módulo foi depreciado no Python 3.3 e posteriormente removido no Python 3.5. fonte - stackoverflow

Consegui resolver o problema criando um virtualenv para trabalhar com o Python Django

Usei esses passos no Linux - Ubuntu 14.04:

Passo 1 - Instalação do gerenciador de pacotes do python "pip"

~$ sudo apt-get install python3-pip

NOTA: No meu caso eu instalei o pip para o python3

Passo 2 - Instalação do virtualenv para o python3

~$ sudo apt-get install python3-venv

Passo 3 - Criando o diretório do projeto

~$ mkdir pasta_do_projeto
~$ cd pasta_do_projeto

Passo 4 - Criando um virtualenv

~$ python3 -m venv myvenv

Passo 5 - Trabalhando com o virtualenv

~$ source myvenv/bin/activate

NOTA: Após ativar o virtualenv, observe que o console terá o indicador (myvenv)

(myvenv)  ~$

Passo 6 - Instalando o Django no virtualenv

(myvenv) ~$ pip install django==1.8.5
Downloading/unpacking django==1.8.5
Installing collected packages: django
Successfully installed django
Cleaning up...

NOTA: Optei por usar a versão do django 1.8.5 ao invés da recomendado no curso que é a 1.7.4, ainda não descobri se isso trará problemas em relação ao curso no futuro.

(myvenv) ~$ django-admin startproject connectedin
(myvenv) ~$ ls
connectedin  myenv
...

Fonte: https://tutorial.djangogirls.org/pt/django_installation/

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software