issue202:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue202:python [2024/02/26 23:21] – créée d52fr | issue202:python [2024/02/28 12:06] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Python and Windows | + | **Python and Windows |
Greetings fellow Beings. Working in Python means that, many times, the need arises to deal with cross-platform programming. Lately, when starting Python, the majority of us need to use ‘python3’, | Greetings fellow Beings. Working in Python means that, many times, the need arises to deal with cross-platform programming. Lately, when starting Python, the majority of us need to use ‘python3’, | ||
- | 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, |
- | 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? | + | 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? | ||
For the last few years, this problem has plagued the Sourceforge PAGE discussion forum. Many users don't bother looking at the previous posts to see if their issue has already been addressed, they seem to think that they are the only ones to have the issue. So the question gets answered multiple times with the same answer. Change the batch file command ‘python3’ to ‘python’ or vice versa. | For the last few years, this problem has plagued the Sourceforge PAGE discussion forum. Many users don't bother looking at the previous posts to see if their issue has already been addressed, they seem to think that they are the only ones to have the issue. So the question gets answered multiple times with the same answer. Change the batch file command ‘python3’ to ‘python’ or vice versa. | ||
- | 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, there was a post that pointed to the Python for Windows documentation about using the shebang line. At first, that didn’t fix the issue for the poster, but for me, it gave me some valuable information. However I had to dig deeper into the documentation. | + | **Eventually, there was a post that pointed to the Python for Windows documentation about using the shebang line. At first, that didn’t fix the issue for the poster, but for me, it gave me some valuable information. However I had to dig deeper into the documentation. |
Since I run Linux for everything, and fire up a Windows machine only when I absolutely must, I never really looked into the “proper” way to install and start Python when it comes to a Windows machine. | Since I run Linux for everything, and fire up a Windows machine only when I absolutely must, I never really looked into the “proper” way to install and start Python when it comes to a Windows machine. | ||
- | The documentation located at https:// | + | The documentation located at https:// |
- | 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.) | + | 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.) | ||
If you have two instances of Python on the Windows machine, ‘py’ will start the latest version, but not the last installed version. | If you have two instances of Python on the Windows machine, ‘py’ will start the latest version, but not the last installed version. | ||
- | 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… |
py -3.10 -v | py -3.10 -v | ||
Ligne 36: | Ligne 64: | ||
- | 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.** |
- | According to the Python https:// | + | 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:// | ||
“If the first line of a script file starts with #!, it is known as a “shebang” line. Linux and other Unix-like operating systems have native support for such lines, and they are commonly used on such systems to indicate how a script should be executed. This launcher allows the same facilities to be used with Python scripts on Windows, and the examples above demonstrate their use. | “If the first line of a script file starts with #!, it is known as a “shebang” line. Linux and other Unix-like operating systems have native support for such lines, and they are commonly used on such systems to indicate how a script should be executed. This launcher allows the same facilities to be used with Python scripts on Windows, and the examples above demonstrate their use. | ||
Ligne 50: | Ligne 94: | ||
“ | “ | ||
- | 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 64: | Ligne 121: | ||
" | " | ||
- | 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.** |
- | That fixed the user’s issue. But how do you get access to the alias settings to turn them off? | + | 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? | ||
It isn’t easy to find. Thankfully the poster was able to give a way to find it. | It isn’t easy to find. Thankfully the poster was able to give a way to find it. | ||
Ligne 76: | Ligne 146: | ||
This will bring up a Settings window that looks something like this. Find the two entries for “App Installer python.exe” and “App Installer python3.exe” and set them to off. | This will bring up a Settings window that looks something like this. Find the two entries for “App Installer python.exe” and “App Installer python3.exe” and set them to off. | ||
- | Close this window and reboot the machine. | + | Close this window and reboot the machine.** |
- | Issue fixed! | + | 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! | ||
That’s all for this month. I’m in the process of rebuilding my home office from a music room / electronics lab into a true office. | That’s all for this month. I’m in the process of rebuilding my home office from a music room / electronics lab into a true office. | ||
Ligne 84: | Ligne 167: | ||
We’ll talk again next month. | We’ll talk again next month. | ||
- | 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.1708986085.txt.gz · Dernière modification : 2024/02/26 23:21 de d52fr