#1 Le 07/05/2025, à 11:28
- Jtomoise
Problème avec python3 #! /usr/bin/env python3 # -*-coding:Utf-8 -*
Bonjour
Mes scripts python3 utilisant matplotlib.pyplot as plt sont éxécutables en mode interpréteur ( instruction par instruction) mais pas en tant que scripts .py .
Ainsi pour le script basique sin.py de la fonction sinus
$ python3 ./Old-Documents/Python/sin.py
Traceback (most recent call last):
File "/home/jean-marc/./Old-Documents/Python/sin.py", line 5, in <module>
import matplotlib.pyplot as plt
File "/home/jean-marc/Old-Documents/Python/matplotlib.py", line 2, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
Le module matplotlib n'est pas trouvé alors que :
:~$ find /usr | grep pyplot
/usr/lib/python3/dist-packages/matplotlib/tests/test_pyplot.py
/usr/lib/python3/dist-packages/matplotlib/tests/__pycache__/test_pyplot.cpython-312.pyc
/usr/lib/python3/dist-packages/matplotlib/pyplot.py
/usr/lib/python3/dist-packages/matplotlib/__pycache__/pyplot.cpython-312.pyc
Une piste peut-être ?
Cordialement
Hors ligne
#2 Le 07/05/2025, à 11:34
- iznobe
Re : Problème avec python3 #! /usr/bin/env python3 # -*-coding:Utf-8 -*
Bonjour , la variable PATH est incomplete ?
echo $PATH
Dernière modification par iznobe (Le 07/05/2025, à 11:37)
retour COMPLET et utilisable de commande | script montage partitions
MSI Z490A-pro , i7 10700 , 32 GB RAM .
Hors ligne
#3 Le 07/05/2025, à 17:21
- Jtomoise
Re : Problème avec python3 #! /usr/bin/env python3 # -*-coding:Utf-8 -*
incomplète ou... mal complétée ???? Puisque :
$ echo $PATH
/usr/lib/python3/dist-packages/matplotlib:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
alors que :
$ find /usr | grep pyplot
/usr/lib/python3/dist-packages/matplotlib/tests/test_pyplot.py
/usr/lib/python3/dist-packages/matplotlib/tests/__pycache__/test_pyplot.cpython-312.pyc
/usr/lib/python3/dist-packages/matplotlib/pyplot.py
/usr/lib/python3/dist-packages/matplotlib/__pycache__/pyplot.cpython-312.pyc
Hors ligne
#4 Le 08/05/2025, à 14:33
- Jtomoise
Re : Problème avec python3 #! /usr/bin/env python3 # -*-coding:Utf-8 -*
Bonjour
Une question basique :
Comment expliquer que l'instruction "import matplotlib.pyplot" soit à l'origine d'un problème révélé par :
"ModuleNotFoundError: No module named 'matplotlib.pyplot'" ?
alors que son importation est présente dans une multitude de scripts Python cités en exemple dans les tutos python ?
En quoi l'installation de Python autoriserait un tel problème ?
Dernière modification par Jtomoise (Le 08/05/2025, à 14:35)
Hors ligne