PySide2 - Possible configuration problem (Solved)

I have just installed PySide2 to compare with PyQt but Atom does not seem to recognize all of its classes.

I tried a basic application:
code:
import sys
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QFile, Qt

if name == “main”:
app = QApplication(sys.argv)
file = QFile(“classMain.ui”)
file.open(QFile.ReadOnly)
loader = QUiLoader()
window = loader.load(file)
window.show()
sys.exit(app.exec_())
#--------------------------------------
and I got following error message:
[Command: python3 -u /home/liamdale/Python/Projects/Pyside2/pyside-2.py]
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
QIODevice::read (QFile, “classMain.ui”): device not open
Designer: An error has occurred while reading the UI file at line 1, column 0: Premature end of document.
Traceback (most recent call last):
File “/home/liamdale/Python/Projects/Pyside2/pyside-2.py”, line 11, in
window = loader.load(file)
RuntimeError: Unable to open/read ui device
[Finished in 0.233s]
#--------------------------------------
It seems to be interpreting the code as PyQt

I have check the code using Python 3.6 Idle IDE and it executes correctly.

Do I have to install a plugin or change the configuration to have Atom work correctly with PySide2

To further test the configuration problem I converted the Ui file into a py file

pyside2-uic -x classMain.ui -o classMain.py

I then programmed ,using Eric-ide, a regular mainWindow using the importing of classMain

Part of the code:
#!/usr/bin/env python

Python Modules

import sys
import datetime

PySide2 Modules

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *

User Modules

import classMain

class mainWindow(QMainWindow, classMain.Ui_MainWindow):
def init(self):

    super(mainWindow, self).__init__()

The code worked - Window was displayed but Atom displayed an error

[Command: /usr/bin/env -u /home/Python/Projects/Pyside2/mainWindow.py]
Traceback (most recent call last):
File “/home/Python/Projects/Pyside2/mainWindow.py”, line 8, in
from PySide2.QtCore import *
ImportError: No module named PySide2.QtCore
[Finished in 0.052s]

I am dipping my toes into the Qt5 (and PyQt) waters and have installed Qt5 to compare with Electron look and feel.

One of my motives are to explore protecting end developed software but Qt5 does come at a hefty commercial licence. I am hovering between different frameworks.

You appear to be on Ubuntu as I am.

I decided to try installing PySide alongside other experiments. I have dismissed PySimpleGUI after a brief test. The PySimpleGUI UI is unappealling based on tkinter.

I document my test run below.

I will say that I saw exactly the same error message outside Atom , that is running python script by command terminal only.

Qt WebEngine seems to be initialized from a plugin. ...

PySide2 is installed in

/usr/local/lib/python3.6/dist-packages/PySide2

If python version is not set correctly PySide2 will not work.

I followed this tutorial (received from Qt site) and I was able to manually launch PySide2 examples.

Atom only needs to be pointed to the correct paths and I suggest that you use process-palette package to reproduce in Atom the test commands used in gnome-terminal or other shell terminal.
e.g.
cd /usr/local/lib/python3.6/dist-packages/PySide2/examples/charts/ &&
python3 memoryusage.py

Thanks d_l for the input;

Unfortunately, I’m getting nowhere. I’ve been working a whole day trying to understand the porcess-palette package for atom with no success.

I have verified the PySide2 installation and it is correct:
Name: PySide2
Version: 5.13.0
Summary: Python bindings for the Qt cross-platform application and UI framework
Home-page: https://www.pyside.org
Author: Qt for Python Team
Author-email: pyside@qt-project.org
License: LGPL
Location: /usr/local/lib/python3.6/dist-packages
Requires: shiboken2

As for shiboken2 in the /usr/local/lib/python3.6/dist-packages folder there is a shiboken2 Folder.

I have executed memoryusage.py in atom and it works. (atom memoryusage.py) Dispite this I still can’t get Atom to execute files from my /home/python/projects/Pyside2 folder.

I know it’s a configuration problem but I am stumped !

You are right concerning my operating system: Mint cinnamon 19.1 (Ubuntu derivative)

Process Palette can be tricky to configure for first time.
Go to Preferences > Packages > Process Palette
Scroll down through Settings

Look for …

Run commands that target files directly from the project tree

Also read under

Generate Configuration

Create a global configuration or a project specific configuration with the respective Do it! buttons.

You will need a project specific command which can simply be run selected file {filepath} with python3.

The command cell will contain python3 (for python3.6 which has PySide installed) and the argument will be the {filepath} to the selected py file in Atom tree-view

There is a direct route into ~/.atom/process-palette.json. But note this under General Configuration (4).

The process-palette.json file can also be edited directly, but then it needs to be reloaded by running Process Palette: Reload Configuration.

There is also an example json file to hack.

Download the example process-palette.json configuration file and place it in the root of your project folder.

Note that you can use {variables} such as {filepath}

toolbar > Packages > Process Palette > toggle

will bring up a list of commands in process pallette

Refer back to this old thread to look for other clues.

[Later thought] There are other packages which might be easier to use than process-palette (but not as powerful in features).

Thanks d_l for your interest but it’s not working .

The Do it buttons give a search dialog and anything i write in it gives me a no match.
The Gui edit form does not permit input.
I have tried displaying in the project tree the chart examples but I can’t seem to find a way to use them.
There is no place that I can identify to modify the path to direct atom to pyside2.

The reference to the Old Threat involves a previous post of mine where I had installed Atom using Flatpak which created an unintentional virtual environment to a folder where Python did not exist. It was corrected by removing Atom with Flatpak and using a conventional installation.

The python-run-terminalnx does not solve the problem either.

I will not for the moment be using Atom for PySide2

Again Thank-you

Just to close this … forget about process-palette for the time being …

Assuming that you have script package installed and Atom reloaded after installing said package.

Load for example memoryusage.py in editor.

Navigate to Packages > Script > Run Script

and PySide2 example launches.

QED

I am guessing that your problem may be $PATH.

Launch terminal in Atom and run echo $PATH

then run command which python3.6 to check that this path is in $PATH

Figured it out!!! got it working.

I copied the memoryusage.py from the root folder to my project folder. Loaded it into atom and it executed correctly.

I then copied the contents into a new file saved if under a new name and again it executed correctly.

I then copied all the coding from my original mainWindow.py from the main class to the end (left out only the PySide2 import section) saved and it executed correctly.

I then went back to my original file looked at the top section to see what was different. The only difference were the comments.

The first one I removed was the SheBang (#!/usr/bin/env python) et Voila the file executed correctly.

The problem was the SheBang !!! problem solved.

One last question I’m asking myself " What is the correct SheBang to use with Atom?" My previous one worked everywhere else.

Again Thanks d_l - It was your last post that started this process. I followed your instructions. everything worked well. Started comparing the PyQt5 and PySide2 installations. Found the snapd PySide2 installation (First attempt at installing PySide2 - it didn’t work), removed it. Tried Atom again. still no sucess. Then I got the Idea to copy the memory Usage file to my project directory … and the rest is history. again thanks for reminding to look for the simple solutions.