我无法导入模块,即使它们与我现在使用的目录相同(E:\Python Projekti\Python Crash Course)。我试图在这里找到解决方案,我想我找到了它与.module\u名称,但它仍然不起作用
我尝试了.module\u name方法,它给了我一个包含所有可能模块的下拉菜单,但最后,它给了我一个终端错误
from .restaurant_module import Restaurant
restaurant = Restaurant('Madera', 'Soulfood')
restaurant.describe_restaurant()
Traceback (most recent call last):
File "E:/Python Projekti/Python Crash Course/Chapter
9/imported_restaurant.py", line 1, in <module>
from .restaurant_module import Restaurant
ModuleNotFoundError: No module named '__main__.restaurant_module';
'__main__' is not a package
我会尝试Jammy建议的:
import restaurant_module
或者尝试在同一个名为__init__.py
的目录中添加一个空白文件,看看是否有效编辑:这个回购有助于你构建它吗https://github.com/ehmatthes/pcc
相关问题 更多 >
编程相关推荐