-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Deprecation of Python 2. Solution #4717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
As for |
Earle was kind to share with me his thoughts about this. Most of the following I am quoting him: "On the 8266 we actually include a python3 portable interpreter for WIN and MACOS and it makes things WAY easier (lets us not need BAT or BASH scripts...all OSes do work in .PYs). On Windows, it's hard to get users to reliably install anything, and there are many different versions (python from the MS store, from cygwin, from python.org, etc.) On Mac, it's even worse as the OS used to include python2, now does not include anything, and the python.org and homebrew installers end up kind of incompatible and not always in the same path or in PATH. So in our package.json there is a python3 tool for Linux, Win, and Mac. (Linux is just a shell script that uses #!/usr/bin/env python3). Then, we simply clone the pyserial and esptool repos as part of our core (i.e. no compiles, it's an actual git submodule). To ensure the proper pyserial is included, we have an upload.py wrapper which includes the distributed pyserial path as a library dir and then calls the esptool.py object to do the actual upload. https://github.com/esp8266/Arduino/tree/master/tools Doing it this way ensures that even on Linux the proper pyserial and esptool version will be used." He also shared with me that you use a Python compiler to build the esptool.exes. So this might be a different approach, but you may come up with a solution inspired from this. I opened also upstream issues with respect to the relevant python scripts. Best regards. |
To the best of my knowledge, the best solution to solve |
Here are the official notes: https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default. Please note the compatibility issues. Installing |
I agree that selecting a default python is a solution. However, that seems temporal and partial. Temporal because it "pushes" the problem forward, that of the ambiguity and that of deprecation. I myself consider the "python" affair (systems dependence on a certain version and set of packages, duality of the language...) something due for improvement since long. The only solution is that everyone uptakes the decision to move forward at certain point. Partial because choosing a default version system-wide means that all programs that are going to need compatibility will be of the same version (aka 3) while it is probably that "older" software still needing support are version 2. |
I agree with these @Martin-Laclaustra. I just don't like hardcoding "python3" into all source files. Similarly, if one has a large set of makefiles then won't hardcode "gcc-10.2.0" everywhere but set it globally like I hope to find a better solution. We already made a breakthrough on the Windows platform where the next installer will unzip an embedded Python which is used only by ESP-IDF and is not registered in Windows. I hope for something similar for Unix platforms in the near future. |
@Martin-Laclaustra 's solution doesn't work 100% for me. On Linux you can set an alias Keep in mind the alias has to be set in the environment of the compiler. |
just changing platform.txt seems to work for me on debian, no need to set a default "python" and break your OS, and no need to edit the scripts as the shebang is not used:
|
Install and export script should work on systems without "python" executable. Closes #6471 Closes #6532 Related to #6421 and espressif/arduino-esp32#4717
Install and export script should work on systems without "python" executable. Closes #6471 Closes #6532 Related to #6421 and espressif/arduino-esp32#4717
Install and export script should work on systems without "python" executable. Closes #6471 Closes #6532 Related to #6421 and espressif/arduino-esp32#4717
Install and export script should work on systems without "python" executable. Closes #6471 Closes #6532 Related to #6421 and espressif/arduino-esp32#4717
Install and export script should work on systems without "python" executable. Closes #6471 Closes #6532 Related to #6421 and espressif/arduino-esp32#4717
Recently I fresh installed Arduino IDE and got ESP32 support. It has not been fixed yet in the official package. This is a critical issue on newer Ubuntu versions (e.g. Focal Fossa), since there is no more Python2 is just obsoleted. As a quick and dirty solution - if necessary - one can make a guaranteed Python3 launcher like this: Move
Voilà, upload works now! |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Yup, Debian Bullseye and RHEL8 have no python2 by default. Its annoying to have to edit the core every time it gets an update, espressif should just change it to not support python2 |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
Yeah, python2 support should be dropped and the python file should be executed directly to use the correct interpreter. |
That worked. Only in latest version of ESP32 package this line has changed:
It still feels a very simple and urgent problem to rectify. @VojtechBartoska |
I confirm that also for Linux Mint. This can do the trick for any version.
|
Slight tweak for macOS:
Works for me on macOS 12.3, Arduino IDE 1.8.19, Python 3.10 |
Seems this can be closed, also this PR was merged: #6448 |
It looks that the most recent platform.txt changed all the calls. Should we wait until a release to close the issue? |
No need, we can close this as it's already in the Master branch. Is now available by manual branch check out. |
Hardware:
Board: ESP32 Dev Module
Core Installation version: 1.0.4
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 460800
Computer OS: Linux Mint 20.1 Ulyssa (base: Ubuntu 20.04 focal)
Description:
Due to deprecation of Python 2 some Linux distributions have decided to remove the generic "python" executable from the path, forcing all code to explicitly declare which version of Python they require (A wise solution in my opinion, as it serves as "canary" for undefined code and prevents obscure errors, resolving the longstanding ambiguity, and still allows the use of older python 2 code). This change has been annoying when one's mind is in other tasks, but one must adapt to new times and deprecation was announced years ago.
Because of this, installing the ESP32 boards in Arduino IDE results in a compilation error and uploading errors. The first error that appears is:
This issue has been raised before, and dismissed in this project:
#3696
#4017
...while it has been addressed early in the independent project "Arduino core for ESP8266":
esp8266/Arduino#6378
Solution:
It seems reasonable to stop forcing users to modify system-wide python setting when the solution seems relatively easy (while I did not weight in possible adaptations needed in other platforms).
I can confirm that the following modification in the "1.0.4" release files fixes the problem.
Files:
only need to change the first line to:
#!/usr/bin/env python3
In file:
esp32/hardware/esp32/1.0.4/platform.txt
, 4 lines need to be changed, just adding a "3":That was enough. However, I do not know if files "sdkconfig" and "sdkconfig.h" would need a change in the lines referring to the flag
CONFIG_PYTHON="python"
, adding the "3".There is still one system-wide dependency to meet, requiring
sudo apt install python3-serial
. I believe that they solved it with a sort of "local copy of the code" in the "Arduino core for ESP8266" project but I do not know the details. May be @earlephilhower could provide some advice on how they did it.I hope that this report is useful and that you decide to uptake the proposed changes.
The text was updated successfully, but these errors were encountered: