ModuleNotFoundError em Python 3.8.3

calvin11

Tenho um problema com as importações de módulos em Python. Estou fazendo um projeto com PyQt e estou tentando refatorá-lo e reestruturá-lo.

A hierarquia é a próxima:

./main.py
./logic/__init__.py
./logic/transforms.py
./logic/hopfield.py
./gui/__init__.py
./gui/interface.py
./gui/mplwidget.py
./img

O erro:

Traceback (most recent call last):
  File "...\main.py", line 5, in <module>
    from gui.interface import Ui_MainWindow
  File ...\gui\interface.py", line 215, in <module>
    from mplwidget import MplWidget
ModuleNotFoundError: No module named 'mplwidget'

O arquivo interface.py

class Ui_MainWindow(object):
  .
  .
  .

from mplwidget import MplWidget

O arquivo main.py

import sys
import matplotlib
import numpy as np

from gui.interface import Ui_MainWindow
from gui.weightMatrix import Ui_Dialog
from gui.table import TableModel

from logic.hopfield import learn, searchPattern
from logic.transforms import transformVector, transformVectors

from PyQt5 import QtCore, QtGui, QtWidgets

class Actions(Ui_MainWindow):
    def __init__(self):
         .
         .
         .

Não entendo por que não funciona, já que dentro do módulo, se eu executar o arquivo de interface, ele funciona bem mplwidgetcomo um módulo.

Lior Cohen

Arquivo ... \ gui \ interface.py ", linha 215, em

from mplwidget import MplWidget

você interface.pydeveria ter

importação absoluta: from gui.mplwidget import MplWidget

ou

importação relativa: from .mplwidget import MplWidget

Além disso, um ótimo blog que explica as duas importações diferentes

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

ModuleNotFoundError em Python 3, mas não 2

Como criar pacotes no Python 3? ModuleNotFoundError

python3 ModuleNotFoundError: No module named 'celery'

ModuleNotFoundError: nenhum módulo nomeado em python 3, mesmo após hackear sys.path ()

Django 3 installed_app mostra ModuleNotFoundError em pastas personalizadas

ModuleNotFoundError em Python

Codificando caracteres para utf-8 hexadecimal em Python 3

String UTF-8 em python 2 e 3

escrever conteúdo utf-8 em arquivos / python 3

Computando 3 ↑↑↑ 3 (em Python)

Python 3.6 ModuleNotFoundError: No module named 'pyttsx3'

Python 3 ModuleNotFoundError: Nenhum módulo chamado 'numpy'

Python 3.6 ModuleNotFoundError: Nenhum módulo chamado 'pyttsx3'

python3 ModuleNotFoundError: No module named 'rest_framework_jwt'

ModuleNotFoundError: No module named 'arrow' python3 django2.2.6

Recuos em python 3

Lambda em Python 3

IndexError em Python 3

impressão UTF-8 em Python 3 usando Sublime Text 3

Python3 'ModuleNotFoundError' ao executar o código por meio do terminal, mas tudo funciona como esperado em um ambiente virtual python

Converter string utf-8 com escape em utf em python 3

Problema na string codificada em utf-8 da impressão em Python 3

Como imprimir texto codificado em UTF-8 para o console em Python <3?

Como imprimir texto codificado em UTF-8 para o console em Python <3?

Como escrever UTF-8 CSV em BytesIO em Python3?

Python 3 - leitura de csv codificado em utf-8 em pandas

ModuleNotFoundError em python (projeto spyder)

ModuleNotFoundError instalando yellowbrick em Python

Como converter chr (0xdfff) em bytes utf-8 no Python 3 como no Python 2?

TOP lista

quentelabel

Arquivo