Tuesday, March 24, 2020

Re: Creating a new Django project, Stuck with the very first steps

Hello, try to uninstall python and install again. Have just one installation of python, 2.7 or 3.5.2 

Em ter, 24 de mar de 2020 08:11, Rodolphe Gohard <rg1693@gmail.com> escreveu:
Hello, I am wanting to create a django project.


But I have encountered multiple problems and am stuck.


My env:
Ubuntu on WSL
python
2.7
python
3.5.2


Here is the steps I took so far:

# create the venv
sudo apt
-get install python3-venv
python3
-m venv pythonenv
source
./pythonenv/bin/activate


python
-m pip install Django
# until there it works


# now, I can't run django-admin startproject diagnosis-admin, fails everytime with a new errors


# pbs with secrets <- pyopenssl <- wheel <- libs
sudo apt
-get install build-essential libssl-dev libffi-dev python3-dev  
pip install wheel
pip install pyopenssl


sudo apt
-get install libsasl2-dev python-dev libldap2-dev libssl-dev
pip install secrets


django
-admin startproject diagnosis-admin

it still fails with an error I don't know what to do with:
(pythonenv) rodolphe@PHP140:~/dev/assistance-tool/diagnosis-admin$ django-admin startproject diagnosis-admin
Traceback (most recent call last):
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/base.py", line 328, in run_from_argv
   
self.execute(*args, **cmd_options)
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/base.py", line 369, in execute
    output
= self.handle(*args, **options)
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/commands/startproject.py", line 18, in handle
    options
['secret_key'] = get_random_secret_key()
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/utils.py", line 82, in get_random_secret_key
   
return get_random_string(50, chars)
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/utils/crypto.py", line 46, in get_random_string
   
return ''.join(secrets.choice(allowed_chars) for i in range(length))
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/utils/crypto.py", line 46, in <genexpr>
   
return ''.join(secrets.choice(allowed_chars) for i in range(length))
AttributeError: module 'secrets' has no attribute 'choice'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/bin/django-admin", line 11, in <module>
    sys
.exit(execute_from_command_line())
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility
.execute()
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 395, in execute
   
self.fetch_command(subcommand).run_from_argv(self.argv)
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/core/management/base.py", line 341, in run_from_argv
    connections
.close_all()
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/db/utils.py", line 225, in close_all
   
for alias in self:
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/db/utils.py", line 219, in __iter__
   
return iter(self.databases)
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/utils/functional.py", line 48, in __get__
    res
= instance.__dict__[self.name] = self.func(instance)
 
File "/mnt/c/Users/gohard.r/dev/assistance-tool/diagnosis-admin/pythonenv/lib/python3.5/site-packages/django/utils/functional.py", line 22, in func
   
'Cannot use cached_property instance without calling '
TypeError: Cannot use cached_property instance without calling __set_name__() on it.
(pythonenv) rodolphe@PHP140:~/dev/assistance-tool/diagnosis-admin$ python --version
Python 3.5.2


I didn't expect so many steps and missing/wrong dependencies, so I guess there must be something wrong in the env, or django/python version, but not sure where to look.

Can anyone help ?






--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b291aeb4-67c0-4089-970b-6ddd084e201d%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABz1GiLaBHUHaVT46wLy%3DVrtKTj_x7DT_Jzj-z-i3NDHap%3Drpw%40mail.gmail.com.

1 comment:

  1. I'm also stuck here. So disappointed. Same error. Could someone please help?

    C:\Users\softech\Desktop\DJANGO>python manage.py startapp mysite
    python: can't open file 'manage.py': [Errno 2] No such file or directory

    C:\Users\softech\Desktop\DJANGO>django-admin startproject mysite
    Traceback (most recent call last):
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "C:\Users\softech\AppData\Local\Programs\Python\Python38-32\Scripts\django-admin.exe\__main__.py", line 7, in
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\core\management\commands\startproject.py", line 20, in handle
    super().handle('project', project_name, target, **options)
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\core\management\templates.py", line 114, in handle
    django.setup()
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\__init__.py", line 16, in setup
    from django.urls import set_script_prefix
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\urls\__init__.py", line 1, in
    from .base import (
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\urls\base.py", line 9, in
    from .exceptions import NoReverseMatch, Resolver404
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\urls\exceptions.py", line 1, in
    from django.http import Http404
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\http\__init__.py", line 1, in
    from django.http.cookie import SimpleCookie, parse_cookie
    File "c:\users\softech\appdata\local\programs\python\python38-32\lib\site-packages\django\http\cookie.py", line 1, in
    from http import cookies
    File "", line 991, in _find_and_load
    File "", line 975, in _find_and_load_unlocked
    File "", line 671, in _load_unlocked
    File "", line 779, in exec_module
    File "", line 915, in get_code
    File "", line 973, in get_data
    OSError: [Errno 9] Bad file descriptor

    C:\Users\softech\Desktop\DJANGO>

    ReplyDelete