PySide2 application failed to start - python-3.x

I just tried to test the newly released version of PySide2 (5.11) on Windows 10, 64 bit version. But the "Hello World" example does not work. I am using Python 3.6 with PyCharm. The interpreter I use is from Anaconda. So I pip installed the PySide2 version and also tried to install via "conda install ..." the older version of PySide2. Both installations worked, but I get the same error message for both libraries.
The error message is popping up in a separate screen saying: "This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: minimal, offscreen, windows."
So I definitely can see the plugin files in the correct folder. I tried reinstalling. Deleted everything and tried other IDEs. But nothing solved the problem.
Any help is appreciated.

Try This :
import sys,os
import PySide2
dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
# code .......
# .......

If you run the app after having set QT_DEBUG_PLUGINS=1, you should get more info on what is the issue. In my case, I was getting:
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/xxxxx/AppData/Local/py3/platforms" ...
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
Such a folder does not exist on my machine.
There are a few tickets somehow related to a similar issue (not sure it is the same problem):
https://bugreports.qt.io/browse/PYSIDE-559
https://github.com/pyside/pyside2-setup/issues/57
https://github.com/conda-forge/matplotlib-feedstock/issues/2
https://github.com/conda-forge/qt-feedstock/issues/71
My current working solution is to remove PyQt, qt and sip anaconda packages, then to manually delete a relic qt.conf in the root folder of the environment. After that, the official PyPi PySide2 wheel works fine.

check whether you have this directory or not: C:\Users\your_user_name\anaconda3\envs\your_virtual_env_name\Library\plugins.
If you don't have it, copy the whole "plugin" folder from your PySide2 site-package.
Mine is in here: C:\Users\your_user_name\anaconda3\envs\your_virtual_env_name\Lib\site-packages\PySide2\plugins
and paste the whole folder to C:\Users\your_user_name\anaconda3\envs\your_virtual_env_name\Library

Related

VSCode Jupiter notebook cannot resolve import for package installed in editable (-e) mode

I am using a Jupyter notebook running in VSCode to test some ideas for a work project and I am using a package that is in a private GitHub repo. I encountered certain conflicts with versions of jax and numpy and after some fiddling trying to fix the issues, I simply re-installed said package to make sure I was using the correct versions of all required packages. Everything seemed fine until I re-opened the notebook and found a bunch of Import "<package name>" could not be resolved Pylance.
The imports still work and the code runs, however, PyLance appears not to be "seeing" said package.
I am using a conda Python 3.8 environment and to re-install the package I ran
pip install -e . --force-reinstall
I have also tried un-installing and re-installing the package, as well as creating a brand new conda env, and then installing the package there. Neither of these options worked however and I was stuck with the same issue.
Upon inspection of what is in sys.path I saw a strange entry
'__editable__.<package_name>-<package_version>.finder.__path_hook__'
I know that a colleague (who does not have this issue) does not see anything similar and instead has the correct local path to the package.
I should also note that I have the Python extension enabled, which includes the Jupyter and Pylance extensions as well. I have tried re-installing those extensions as well and that did not solve the issue either.
Edit.
I will add that I only get this PyLance error in notebooks. If I open a regular Python file then all PyLance features appear to be working as expected.

Can install PyQt5-sip for one Venv but not for another one! (Pycharm/Win10)

I have a severe compability issue with a Pycharm PyQt5 project that I cannot solve:
Problem Description:
I ran into a compability problem when I try to install PyQt5 site packages in my Pycharm editor.
The strange thing is that I could install PyQt5 and used it before in another Pycharm Project about 2 months earlier.
Both projects have two different virtual environments, both created by Pycharm when creating a new environment.
Screenshot of installed packages of the old, working venv:
Screenshot of installed packages of the new, broken venv:
What I tried to narrow down the error:
I checked if PyQt5 is still installed in my Python:
Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\users\mauser\appdata\local\programs\python\python38-32\lib\site-packages (from PyQt5) (12.8.1)
The Error Log shows that PyCharm fails to install PyQt5-sip into the new virtual environment
Next, I updated both, globally, and locally (in the new project venv), pip and setuptools
The error log then told me that it needs Microsoft Visual C++ 14.0 or higher, so I installed the newest version of VC building tools and also included the version that actually says version 14.00.
Then I installed / upgraded PEP517 since the end of the error log states:
ERROR: Failed building wheel for PyQt5-sip
ERROR: Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed directly
It seems that when pip is trying to build PyQt5-sip inside the virtual environment, that somehow the VC+ buildtools fail?
"basetsd.h": No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\cl.exe' failed with exit status 2
Finally, I made a new project and tried to install PyQt5 in this fresh virtual environment. It failed with the same error: PyQt5-sip cannot be built Anymore!
Conclusion:
Why did it work last time, when I installed, and used PyQt5 without any problems?
Why can I install just fine: PyQt5, sip, and Qt designer on my machine globally but suddenly not locally anymore?
Qt designer still works, pip tells me that PyQt5 is correctly installed globally!
There was a recent Windows 10 patch - was this the reason? Did I maybe not install the correct VC+ 14.00 distribution?
Can I simply copy the PyQt5 folder from the old venv without breaking anything to bypass this problem? (Did not dare to try this out yet)
The answer to this is:
A Win10 update corrupted some parts of the Visual C++ 14.00 package on my system.
So hopefully this may help some others.
I deleted every VC++ package I had previously installed and (once more) installed the essential VC++ buildtools 2019, build 16.9.5..
Optional Features chosen:
Core Tools and Test Package
MSVC 142
MSVC 140
C++ CMake Tools
Win10 SDK
It seems that you need to include the SDK package as well to make it work!
After having reinstalled cleanly these packages above, PyQt5 and namely PyQt5-sip are able to be built again!

Where is IPython.frontend.terminal.embed package for Anaconda3?

I have pulled the source code for SfePy from GitHub with the objective of building and running it locally.
I'm running on Ubuntu 20.10 using Anaconda3. I have PyCharm 2020.2 from Jetbrains as my IDE.
When I bring the code into PyCharm I see several errors about missing packages. One of them is in the base.py file:
except NameError:
from IPython.frontend.terminal.embed \
import InteractiveShellEmbed
The IDE tells me that the terminal package is not installed. It is not found when I try to install.
I searched for it at Anaconda.org, but no joy.
This is an active code base. There was a commit made just today.
How can it be that this code won't build? What am I missing? How can I find a replacement so I can build this app?
I got an answer on the SfePy GitHub issues page:
conda install sfepy
brings in all the dependencies. I'm able to successfully run all the unit tests:
sfepy-run run_tests
When I open PyCharm the compilation problems are resolved.

Anaconda navigotor and its applications wont work

Anaconda navigator along and its enclosed applications stopped working when qtpy4 package was inserted manually, clicking their .exe icons wont raise any errors as nothing happens.
But upon manual launch of
C:\ProgramData\Anaconda2\Scripts\anaconda-navigator.exe
or
C:\ProgramData\Anaconda2\Scripts\spyder.exe
Raised the attached error
Qtpy error
*It is worth mentioning jupyter-notebook.exe launched from
C:\ProgramData\Anaconda2\Scripts\jupyter-notebook.exe
Worked fine
A simple reinstall sufficed, turns out the problem was in pipeline for pyqt as it broke conflicting qt5 binding.
P.s Happened when I accidentally install qt4 package over already
existing qt5 package in anaconda.

Error installing Pygame / Python 3.4.1

I'm trying to install Pygame and it returns me the following error "Python version 3.4 required which was not found in the registry". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem?
I've been using Windows 8.1
Thanks in advance.
Are you using a 64-bit operating system? Try using the 32-bit installer.
Tips I can provide:
Add Python to your Path file in the Advanced settings of your Environmental Variables (just search for it in the control panel)
Something may have gone wrong with the download of Python, so re-install it. Also don't download the 64-bit version, just download the 32-bit version from the main pygame website
Once that's sorted out, transfer the entire Pygame file to the site packages in the Python directory and open up the pygame file and go to this directory in command prompt. Finally, run the Pygame setup from the command prompt which should be something like:
python setup.py
But this will only work if the pygame setup file is called setup.py (it's been a while since I downloaded it), you added Python to the Path file and you're currently in the correct directory in command prompt.
To test if it worked try importing pygame and see if you got an error or not.

Resources