Error while using python -m django --version
Bonjour,
je rencontre une erreur en executant la commande :
python -m django --version
-> ModuleNotFoundError: No module named 'distutils'
Comme si l'installation du module django ne s'était automatiquement pas faite avec toutes les dépendances nécessaires.
De même, quand je lance la commande Python pour un interpréteur python interactif, rien ne se passe.
J'ai suivi le cours jusqu'alors, créé et activé mon environnement virtuel, je suis sous windows avec git bash. (WSL2 ne semble pas bien répondre, et dual boot linux temporairement défaillant)
(.env)
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ pip install --upgrade pip
Requirement already satisfied: pip in c:\python\docstring\docblog\.env\lib\site-packages (24.0)
Collecting pip
Downloading pip-24.1.1-py3-none-any.whl.metadata (3.6 kB)
Downloading pip-24.1.1-py3-none-any.whl (1.8 MB)
---------------------------------------- 1.8/1.8 MB 5.1 MB/s eta 0:00:00
ERROR: To modify pip, please run the following command:
C:\python\docstring\DocBlog\.env\Scripts\python.exe -m pip install --upgrade pip
[notice] A new release of pip is available: 24.0 -> 24.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
(.env)
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ pip install django==3.1.6
Collecting django==3.1.6
Downloading Django-3.1.6-py3-none-any.whl.metadata (3.7 kB)
Collecting asgiref<4,>=3.2.10 (from django==3.1.6)
Downloading asgiref-3.8.1-py3-none-any.whl.metadata (9.3 kB)
Collecting pytz (from django==3.1.6)
Using cached pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting sqlparse>=0.2.2 (from django==3.1.6)
Downloading sqlparse-0.5.0-py3-none-any.whl.metadata (3.9 kB)
Downloading Django-3.1.6-py3-none-any.whl (7.8 MB)
---------------------------------------- 7.8/7.8 MB 6.9 MB/s eta 0:00:00
Downloading asgiref-3.8.1-py3-none-any.whl (23 kB)
Downloading sqlparse-0.5.0-py3-none-any.whl (43 kB)
---------------------------------------- 44.0/44.0 kB 2.1 MB/s eta 0:00:00
Using cached pytz-2024.1-py2.py3-none-any.whl (505 kB)
Installing collected packages: pytz, sqlparse, asgiref, django
Successfully installed asgiref-3.8.1 django-3.1.6 pytz-2024.1 sqlparse-0.5.0
[notice] A new release of pip is available: 24.0 -> 24.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
(.env)
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ python -m django --version
Traceback (most recent call last):
File "<frozen runpy="">", line 189, in _run_module_as_main
File "<frozen runpy="">", line 148, in _get_module_details
File "<frozen runpy="">", line 112, in _get_module_details
File "C:\python\docstring\DocBlog\.env\Lib\site-packages\django\__init__.py", line 1, in <module>
from django.utils.version import get_version
File "C:\python\docstring\DocBlog\.env\Lib\site-packages\django\utils\version.py", line 6, in <module>
from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
(.env)
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ python
Merci par avance de votre aide !
Salut Geoffroy,
Je vois que tu essaies d'installer la version 3.1.6 de Django. Distutils a été enlevé dans Python 3.12, je te conseille d'essayer avec l'installation d'une version plus récente de Django (tu peux juste enlever le ==3.1.6 et installer la dernière version).
Dis-moi si ça fonctionne sinon on regardera ailleurs (tu peux aussi installer distutils avec pip install setuptools si tu souhaites conserver cette version de Django).
Merci pour ton retour Thibault.
Lorsque j'essaie d'installer la dernière version de django et d'en tester la version ensuite, j'obtiens ces messages d'erreurs.
Il ne semble pas désinstaller la version précédente avant d'y installer la nouvelle.
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ pip install django
Requirement already satisfied: django in c:\python\docstring\docblog\.env\lib\site-packages (3.1.6)
Requirement already satisfied: asgiref<4,>=3.2.10 in c:\python\docstring\docblog\.env\lib\site-packages (from django) (3.8.1)
Requirement already satisfied: pytz in c:\python\docstring\docblog\.env\lib\site-packages (from django) (2024.1)
Requirement already satisfied: sqlparse>=0.2.2 in c:\python\docstring\docblog\.env\lib\site-packages (from django) (0.5.0)
[notice] A new release of pip is available: 24.0 -> 24.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
(.env)
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ python -m django --version
Traceback (most recent call last):
File "<frozen runpy="">", line 189, in _run_module_as_main
File "<frozen runpy="">", line 148, in _get_module_details
File "<frozen runpy="">", line 112, in _get_module_details
File "C:\python\docstring\DocBlog\.env\Lib\site-packages\django\__init__.py", line 1, in <module>
from django.utils.version import get_version
File "C:\python\docstring\DocBlog\.env\Lib\site-packages\django\utils\version.py", line 6, in <module>
from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
(.env)
En installant alors setuptools, alors j'obtiens bien :
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ python -m django --version
3.1.6
(.env)
Si par contre à la suite je lance la commande python pour un interpréteur python interactif, rien ne se passe pendant un temp puis...
(.env)
Hylst@HYLST-LAPTOP MINGW64 /c/python/docstring/DocBlog
$ python
object address : 0000026E16D09260
object refcount : 3
object type : 00007FFD3B5E1EB0
object type name: SyntaxError
object repr : SyntaxError('invalid non-printable character U+001B', ('<stdin>', 4, 1, '\x1b[A\x1b[A\x1b[A\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B\x1b[B', 4, 1))
lost sys.stderr
(.env)
Merci pour ton aide.
Inscris-toi
(c'est gratuit !)
Tu dois créer un compte pour participer aux discussions.
Créer un compte