Importerror:NO模块名为' sdcard'
我正在使用 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'
如何解决导入?
注意:
- 我尝试附加附加
'。
和'/'
tosys
,它不起作用。例如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'/'
tosys
, it does not work. e.gsys.path.append('/')
- I tried different versions of import, no luck. e.g
from lib import SDCard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然Thonny允许您运行从本地计算机打开的文件,但它仅允许从其自己的内部存储中导入模块。
对我来说,这令人困惑。
我在所有模块文件上运行了“保存复制...”,选择了“ Raspberry pi pico”,然后手动输入文件名。
也许还有另一种方法在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.
Maybe there is another way of doing this in Thonny, as this is my first time using MicroPython on RPi Pico.