Unsolved ModuleNotFoundError: when importing from "__feature__"
-
I have installed PySide6 into a clean python 3.8.x environment using
pip install pyside6
However when I try to import from the __features__ module I get the following Traceback
Traceback (most recent call last):
File "C:/Users/miket/Projects/PySide6_Training/custom_main_win.py", line 2, in <module>
from __feature__ import snake_case, true_property
ModuleNotFoundError: No module named '__feature__'Any thoughts on what might be causing this?
-
Hi and welcome to devnet,
Which OS are you running ?
Can you provide a minimal runnable script that shows the issue ? -
Sure. I'm on Windows 10 writing code in PyCharm
The following works
import sys from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("My App") # This is the old way using the set function button = QPushButton("Click Me") button.setEnabled(False) self.setCentralWidget(button) app = QApplication([]) window = MainWindow() window.show() sys.exit(app.exec_())
While this code throws the previously listed Traceback stating the ModuleNotFoundError
import sys from __feature__ import snake_case, true_property from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("My App") # This is using the functionality from __feature__ button = QPushButton("Click Me") button.enabled = False self.setCentralWidget(button) app = QApplication([]) window = MainWindow() window.show() sys.exit(app.exec_())
-
@Tallhamer
__feature__
must be imported after PySide6, also you must changesetCentralWidget
toset_central_widget
:import sys from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton from __feature__ import snake_case, true_property class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("My App") # This is using the functionality from __feature__ button = QPushButton("Click Me") button.enabled = False self.set_central_widget(button) app = QApplication([]) window = MainWindow() window.show() sys.exit(app.exec_())