• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

When installing DateTime or any packages using Thonny Tools-Manage Plug-ins

Q&A Forum › When installing DateTime or any packages using Thonny Tools-Manage Plug-ins
0 Vote Up Vote Down
alex soriano asked 3 years ago

I get this error message:

Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ImportError: no module named ‘DateTime’

5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Alex.
Can you provide more details about your issue?
What did you install and how? And what code are you trying to run?
You’re probably getting that error because the module you’re trying to import is not “installed/uploaded” to your board.
Regards,
Sara

0 Vote Up Vote Down
alex soriano answered 3 years ago

Hi Sara,
I use the “Manage Plug-ins” in Tools of Thonny. I enter the package I want imported and press “Find package from PyPI”. The package is installed and I can see the package imported in the list on the left. It is also in the folder “home/user/.local/lib/python3.7/site-packages”. I’m trying to install DateTime and schedule packages so I can use them to code. However, when I import the package, Thonny gives me the error I previously mentioned.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Alex.

Thonny IDE is a Python IDLE that also supports MicroPython on ESP32/ESP8266 devices. This means you can also write Python programs and run then on your computer.

When you install packages as you did, you’re installing the packages locally on your computer. This would work if you were running Python on your computer.

In this case, you’re running MicroPython not on your computer, but on your ESP32 or ESP8266 boards. So the libraries need to be installed/imported to the ESP boards.

By default, you can use the utime library: http://docs.micropython.org/en/latest/library/utime.html

You can also import the datetime library adapted for MicroPython: https://github.com/micropython/micropython-lib/blob/master/datetime/datetime.py

Basically, create a file called datetime.py with the datetime.py content and import it to the ESP32 board. Then, you can use the library functions on your code. Learn more about installing libraries on the eBook, page 351.

I hope this helps.

Regards,
Sara

0 Vote Up Vote Down
alex soriano answered 3 years ago

A newbie mistake. I use Thonny to flash my ESP8266 and did not change back the python interpreter back to the default used by Thonny and the current python program after I finished flashing. I hope this helps others.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Great!
I’ll mark this question as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.