1

I'm using a Ubuntu 22.04 and Arduino IDE 1.8.19 for my ESP8266 Projects.

Yesterday I upgraded to 3.1.1 (using board library manager), and right after that - I got the following message (few seconds after compilation start):

Traceback (most recent call last):
  File "/home/guy/snap/arduino/85/.arduino15/packages/esp8266/hardware/esp8266/3.1.1/tools/mkbuildoptglobals.py", line 846, in <module>
    sys.exit(main())
  File "/home/guy/snap/arduino/85/.arduino15/packages/esp8266/hardware/esp8266/3.1.1/tools/mkbuildoptglobals.py", line 759, in main
    if time.time_ns() < os.stat(commonhfile_fqfn).st_mtime_ns:
AttributeError: module 'time' has no attribute 'time_ns'
exit status 1
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

Steps done to find the reason:

  1. Empty Sketch - occurs.
  2. Any other ESP8266 board - occurs.
  3. Going back to prior version, 3.1.0 - occurs.
  4. Going back to 3.0.2 - OK!
  5. Checking 3.1.1 on Mac, same IDE version - OK!

Any ideas why ? Am I the only one ?

Guy

7
  • The error tells you, that the time.time_ns() python function does not exist. This function was added to the python time lib with Python3 version 3.7. The most likely scenario I can imagin here is, that a python 3.6 or lower version is installed on your ubuntu and therefor the board software does not find the requiered function. Open a terminal and enter python --version or python3 --version, and make sure you have at least python V 3.7 installed. I would recommend to install 3.10+ to have the newest version and avoid missing other libs and language features. Jan 21, 2023 at 11:42
  • @PeterPaulKiefer Typing guy@linux:~$ python3 --version returned Python 3.10.6
    – guyd
    Jan 21, 2023 at 18:24
  • i have the same problem Ubuntu 22.04 IDE 1.8.19 Python 3.10.6 Error occurs after upgrading board esp8266 to 3.1.1 Jan 31, 2023 at 14:08
  • 2
    Sorry for my late answer. You installed the Arduino IDE with snap?! It is possible, that Snap has its own python dependencies. I often had such problems when using snap instead of installing the software with apt or manually with a tarball. Now I always install Arduino using the tarball. There are many doc in the internet, here is one example: linuxopsys.com/topics/install-arduino-ide-on-ubuntu-20-04 Feb 2, 2023 at 11:18
  • 1
    I had the same problem, although having python 3.8 installed, and I also installed Arduino through Snap. After removing the Snap installation and installing the one from arduino's website (the .AppImage file) - the issue with time_ns went away. Tnx@PeterPaulKiefer. You transform your comment into an answer and I'd gladly vote for it.
    – userfuser
    Mar 5, 2023 at 9:49

1 Answer 1

1

The error tells you, that the time.time_ns() python function does not exist. This function was added to the python time lib with Python3 version 3.7.

The most likely scenario I can imagin here is, that a python 3.6 or lower version is installed on your ubuntu and therefore the board software does not find the required function.

Depending on how the ARDUINO IDE is configured, the globally installed python or a special installation of python is used. We dicussed these two possibilities in the chat and realized that in your case, snap installs its own dependency of python. I assume that the version of this python was below 3.7 and therefore the plugin was unable to find the required time function.

If the Arduino IDe would have been depent on the global python installation, it would have been enough to install a newer python (e.g. 3.10+) globally.

In you case (dependency defined by snap), the only solution I have, is to install the IDE not with snap but with the manual installation or by using apt. There are instruction in the internet like https://www.computingpost.com/how-to-install-arduino-ide-on-ubuntu-22-04-lts/.

Please check the comment of @userfuser (about usíng an .AppImage file) in the dicussion below the question also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.