issue202:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue202:python [2024/02/27 06:58] – d52fr | issue202:python [2024/02/28 12:06] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
Some of us have aliased python3 to simply ‘python’ and pip3 to ‘pip’. This is especially easy with pyenv. Unfortunately, | Some of us have aliased python3 to simply ‘python’ and pip3 to ‘pip’. This is especially easy with pyenv. Unfortunately, | ||
+ | |||
+ | Python et Windows | ||
+ | |||
+ | Bonjour à tous. Travailler en Python signifie qu'il est souvent nécessaire de s' | ||
+ | |||
+ | Certains d' | ||
+ | |||
**So how do you create a batch file to make the startup process simple, and to work in every instance, and create a shebang that will work every time as well? | **So how do you create a batch file to make the startup process simple, and to work in every instance, and create a shebang that will work every time as well? | ||
Ligne 10: | Ligne 17: | ||
Back in December, the Python-list digest had a thread about the shebang line no longer working correctly when running Python 3.12 under Windows 11. Knowing that this could trouble PAGE users, I started following the thread with interest. As expected, there were a number of responses that contained a “Well, it worked for me” kind of response but many of the responses were seriously trying to help the poster, without a definitive answer.** | Back in December, the Python-list digest had a thread about the shebang line no longer working correctly when running Python 3.12 under Windows 11. Knowing that this could trouble PAGE users, I started following the thread with interest. As expected, there were a number of responses that contained a “Well, it worked for me” kind of response but many of the responses were seriously trying to help the poster, without a definitive answer.** | ||
+ | |||
+ | Alors, comment créer un fichier batch pour simplifier le processus de démarrage, pour qu'il fonctionne dans tous les cas et pour créer un « shebang » (un truc complet) qui fonctionnera également à chaque fois ? | ||
+ | |||
+ | Ces dernières années, ce problème a tourmenté le forum de discussion de PAGE sur Sourceforge. De nombreux utilisateurs ne prennent pas la peine de consulter les messages précédents pour voir si leur problème n'a pas déjà été abordé, car ils semblent penser qu'ils sont les seuls à avoir ce problème. La question est donc traitée plusieurs fois avec la même réponse. Dans le fichier batch, remplacez la commande « python3 » par « python » ou vice versa. | ||
+ | |||
+ | En décembre dernier, le digest de la liste Python contenait un fil de discussion sur le fait que la ligne de « shebang » ne fonctionnait plus correctement lors de l' | ||
+ | |||
**Eventually, | **Eventually, | ||
Ligne 16: | Ligne 30: | ||
The documentation located at https:// | The documentation located at https:// | ||
+ | |||
+ | Finalement, un post a pointé vers la documentation de Python pour Windows à propos de l' | ||
+ | |||
+ | Comme j' | ||
+ | |||
+ | La documentation disponible à l' | ||
+ | |||
**It turns out that, as far back as Python 3.3, there has been a launcher for Windows, and the command to use the launcher is simply ‘py’ . You can still use python or python3, depending on how your python got installed, but the ‘py’ command will start python regardless. (There is a small caveat here. If Python 2.x was previously installed, the launcher might not have been installed correctly.) | **It turns out that, as far back as Python 3.3, there has been a launcher for Windows, and the command to use the launcher is simply ‘py’ . You can still use python or python3, depending on how your python got installed, but the ‘py’ command will start python regardless. (There is a small caveat here. If Python 2.x was previously installed, the launcher might not have been installed correctly.) | ||
Ligne 22: | Ligne 43: | ||
You can find all the versions that the Windows launcher will provide by doing a ‘py --list’ in the command prompt (shown below).** | You can find all the versions that the Windows launcher will provide by doing a ‘py --list’ in the command prompt (shown below).** | ||
+ | |||
+ | Il s' | ||
+ | |||
+ | Si vous avez deux instances de Python sur la machine Windows, la commande « py » lancera la version la plus récente, mais pas la dernière version installée. | ||
+ | |||
+ | Vous pouvez trouver toutes les versions que le lanceur Windows fournira en faisant « py --list » dans l' | ||
+ | |||
**In the below screen print, version 3.12 will be the default whenever ‘py’ is called. If you want to use version 3.10 instead, simply call py with the version you want. For example… | **In the below screen print, version 3.12 will be the default whenever ‘py’ is called. If you want to use version 3.10 instead, simply call py with the version you want. For example… | ||
Ligne 37: | Ligne 65: | ||
It shows only two versions, not three, and the second version is actually a zero-byte file. This is where the issue with the shebang comes in.** | It shows only two versions, not three, and the second version is actually a zero-byte file. This is where the issue with the shebang comes in.** | ||
+ | |||
+ | Dans la capture d' | ||
+ | |||
+ | py -3.10 -v | ||
+ | |||
+ | renverra la version 3.10.10 (dans mon cas). | ||
+ | |||
+ | Il y a une chose curieuse à propos de Python et Windows. De nombreuses personnes ont suggéré d' | ||
+ | |||
+ | C: | ||
+ | C: | ||
+ | C: | ||
+ | |||
+ | |||
+ | Il n' | ||
+ | |||
**According to the Python https:// | **According to the Python https:// | ||
Ligne 52: | Ligne 96: | ||
Of course, the first three versions of the accepted virtual commands couldn’t possibly exist on Windows, but the launcher is supposed to handle them.** | Of course, the first three versions of the accepted virtual commands couldn’t possibly exist on Windows, but the launcher is supposed to handle them.** | ||
- | **The problem can come from that zero-byte file I pointed out a few moments ago. In fact, when I started fighting the problem on my virtual Windows machine, I had the following zero byte files… | + | D' |
+ | « Si la première ligne d'un fichier de script commence par #!, il s'agit d'une ligne « shebang ». Linux et d' | ||
+ | Pour permettre aux lignes shebang des scripts Python d' | ||
+ | |||
+ | / | ||
+ | / | ||
+ | / | ||
+ | python | ||
+ | " | ||
+ | |||
+ | Bien sûr, les trois premières versions des commandes virtuelles acceptées ne peuvent pas exister sous Windows, mais le lanceur est censé les gérer. | ||
+ | |||
+ | |||
+ | **The problem can come from that zero-byte file I pointed out a few moments ago. In fact, when I started fighting the problem on my virtual Windows machine, I had the following zero byte files… | ||
C: | C: | ||
Ligne 65: | Ligne 122: | ||
I’ve never heard of this happening on a Windows 10 machine, but I suppose it COULD happen. Anyway, message after message came, suggestions were made, but there was nothing definitive that would fix the user’s problem until January 16. Finally someone suggested that Windows 11 was failing at the zero-byte Alias stub files. The suggestion was to turn off access to the Python stub files.** | I’ve never heard of this happening on a Windows 10 machine, but I suppose it COULD happen. Anyway, message after message came, suggestions were made, but there was nothing definitive that would fix the user’s problem until January 16. Finally someone suggested that Windows 11 was failing at the zero-byte Alias stub files. The suggestion was to turn off access to the Python stub files.** | ||
+ | |||
+ | Le problème peut venir de ce fichier de zéro octet que j'ai signalé il y a quelques instants. En fait, lorsque j'ai commencé à m' | ||
+ | |||
+ | C: | ||
+ | |||
+ | C: | ||
+ | |||
+ | Pour une raison quelconque, ces fichiers de zéro octet peuvent parfois provoquer, sur une machine Windows 11, un message similaire à : | ||
+ | |||
+ | « Unable to create process using ' | ||
+ | |||
+ | Je n'ai jamais entendu dire que cela se produisait sur une machine Windows 10, mais je suppose que cela PEUT arriver. Quoi qu'il en soit, les messages se sont succédé, des suggestions ont été formulées, mais rien de définitif n'a permis de résoudre le problème de l' | ||
+ | |||
**That fixed the user’s issue. But how do you get access to the alias settings to turn them off? | **That fixed the user’s issue. But how do you get access to the alias settings to turn them off? | ||
Ligne 77: | Ligne 147: | ||
Close this window and reboot the machine.** | Close this window and reboot the machine.** | ||
+ | |||
+ | Cela a permis de résoudre le problème de l' | ||
+ | |||
+ | Ce n'est pas facile à trouver. Heureusement, | ||
+ | |||
+ | Windows dispose d'un champ de recherche sur le panneau situé juste à côté du menu Démarrer. | ||
+ | |||
+ | Il suffit de taper (ou même de commencer à taper) « Manage app execution aliases » (Gérer les alias d' | ||
+ | |||
+ | Une fenêtre de paramètres s' | ||
+ | |||
+ | Fermez cette fenêtre et redémarrez la machine. | ||
+ | |||
**Issue fixed! | **Issue fixed! | ||
Ligne 85: | Ligne 168: | ||
Until next time, as always; stay safe, healthy, positive and creative!** | Until next time, as always; stay safe, healthy, positive and creative!** | ||
+ | |||
+ | Problème résolu ! | ||
+ | |||
+ | C'est tout pour ce mois-ci. Je suis en train de reconstruire mon bureau à domicile pour en faire un véritable bureau. | ||
+ | |||
+ | Nous en reparlerons le mois prochain. | ||
+ | |||
+ | Jusqu' | ||
issue202/python.1709013511.txt.gz · Dernière modification : 2024/02/27 06:58 de d52fr