Importerror:NO模块名为' sdcard'

发布于 2025-02-05 11:38:33 字数 1081 浏览 3 评论 0原文

我正在使用 Thonny 版本3.3.13在 Windows 10 上进行程序 Raspberry pi pico

主程序是main.py。除了任何本地进口,我都没有问题(示例正在奏效)。
我关注 this教程

它并没有重复,因为我在Stackoverflow和许多其他网站上搜索并测试了许多版本的导入数小时。

我的文件结构:

sd_card_read
  |-main.py
  |-lib
     |-__init__.py
     |-SDCard.py

我的main.py文件:

import sys
print(sys.path)

import SDCard

#... the rest of the code

我遇到的错误是:

['', '.frozen', '/lib']
Traceback (most recent call last):
  File "<stdin>", line 10, in <module>
ImportError: no module named 'SDCard'

如何解决导入?

注意:

  • 我尝试附加附加'。'/' to sys,它不起作用。例如sys.path.append('/')
  • 我尝试了导入的不同版本,没有运气。例如来自lib import sdcard

I'm using Thonny version 3.3.13 on Windows 10 to program Raspberry Pi Pico.

The main program is main.py. I have no issues with it (examples are working), except any local imports.
I'm following this tutorial.

It is not duplicated, as I've searched and tested many version of import on StackOverflow and many other websites for hours.

My file structure:

sd_card_read
  |-main.py
  |-lib
     |-__init__.py
     |-SDCard.py

My main.py file:

import sys
print(sys.path)

import SDCard

#... the rest of the code

The error I'm getting is:

['', '.frozen', '/lib']
Traceback (most recent call last):
  File "<stdin>", line 10, in <module>
ImportError: no module named 'SDCard'

How can I solve the import?

Notes:

  • I tried appending '.' and '/' to sys, it does not work. e.g sys.path.append('/')
  • I tried different versions of import, no luck. e.g from lib import SDCard

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深如许 2025-02-12 11:38:33

虽然Thonny允许您运行从本地计算机打开的文件,但它仅允许从其自己的内部存储中导入模块。

对我来说,这令人困惑。

我在所有模块文件上运行了“保存复制...”,选择了“ Raspberry pi pico”,然后手动输入文件名。

”在哪里保存到?”

”保存到覆盆子pi

也许还有另一种方法在thonny中这样做,因为这是我第一次在rpi pico上使用micropopropython。

While Thonny allows you to run a file opened from your local computer, it ONLY allows importing modules from its own internal storage.

For me, this is confusing.

I ran "Save copy..." on all my module files, chose "Raspberry Pi Pico" and entered the filename manually.

Save copy...

Where to save to?

Save to Raspberry Pi Pico

Maybe there is another way of doing this in Thonny, as this is my first time using MicroPython on RPi Pico.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文