relative-import

Relative import error with py2exe

女生的网名这么多〃 提交于 2019-11-26 18:32:04
问题 I was trying to generate an executable for a simple Python script. My setup.py code looks like this: from distutils.core import setup import py2exe setup(console=["script.py"]) However, I am getting the error shown in the screenshot. Is there something I could try to fix this? I am using Windows 10. 回答1: It seems that in your mf3.py you are importing beyond the top level. Let's suppose that your project structure is as follows: folder/ main.py mod/ __init__.py components/ __init__.py expander

Relative imports - ModuleNotFoundError: No module named x

可紊 提交于 2019-11-26 12:18:20
问题 This is the first time I\'ve really sat down and tried python 3, and seem to be failing miserably. I have the following two files: test.py config.py config.py has a few functions defined in it as well as a few variables. I\'ve stripped it down to the following: However, I\'m getting the following error: ModuleNotFoundError: No module named \'config\' I\'m aware that the py3 convention is to use absolute imports: from . import config However, this leads to the following error: ImportError: