[NEED HELP] ImportError PySide2.QtCore
-
Hi everyone,
I've just installed PySide2 and Shiboken2 by
pip install PySide2
command. However, when I try to importPySide2.QtCore
, it raised an errorImportError: DLL load failed: The specified procedure could not be found.
(I imported PyQt5 and it worked fine)I'm new with PyQt, hope you can help me. Thank you so much.
-
Hi,
How did you install Python ?
Which version is it ?
Which version of PySide2 is it exactly ? -
Hi @SGaist ,
I installed Python in the same folder with Anaconda (C:\) and the version is 3.7
The version of PySide2 is 5.12.2
Thanks a lot -
@Lucas_1603 said in [NEED HELP] ImportError PySide2.QtCore:
I installed Python in the same folder with Anaconda (C:)
This sound a bit frightening. Did you manually install Python on top of anaconda ?
-
Ok, did you create a dedicated environment with conda ?
Do you maybe have both the pip and conda version of PySide2 installed ?
Any rogue Qt version installed ? -
@SGaist
I haven't created any environment with conda yet
I think pip, conda version and Qt are fine.When I install PySide2 via pip, it installed these in Anaconda:
Here is the path to the location of Python:
PySide2 is installed in Anaconda instead of Python, is that right? Whether it's the reason why Python can't recognize the library?
Any PATH update or environment is needed? I'm not well aware of those so if yes, please guide me in more detail ^^
Thank you so much
-
Something looks strange.
If you have nothing special in your conda environment, I would reinstall it from scratch and then create a new environment where you will install PySide2. That way you ensure that your environment is clean. You will also be able to inspect it more easily and not mix dependencies you would not need from other environnement.
-
Hi @SGaist ,
Where should DLL files be and what are they?
Could I find those DLL files and move or copy them to the right folder? -
I do not have a Windows machine at hand but at least on *nix like OSs everything is stored in the sub-folder of the environment you created. That's why I am suggesting to start clean to ensure you do not have stray items. Moving dlls around is rarely the good solution.
-
Hi @SGaist ,
Actually, I created a new environment by following this guide: https://doc.qt.io/qtforpython-5/quickstart.html
Here is what I actually did:>>> pip uninstall PySide2 >>> python -m venv env/ >>> env\Scripts\activate.bat >>> pip install PySide2
However, when I import PySide2, it raised an error
Modulenotfounderror: NO module named "PySide2"
My questions are:
- Do I need to install anything else in that new environment?
- How to check what is the current environment that my program is running?
- In case I have more than one environment, how to force the program runs on a specific one (which is the newly created)?
Thank you so much
-
@Lucas_1603
Have a look at what is in thatenv\Scripts\activate.bat
. This is what is causing the conda environment to be activated. You will need those settings, whether running your PySide2 program from within an IDE (like Creator) or from a Command Prompt/shortcut icon outside of anything else. -
Hi @JonB,
Here is what myenv\Scripts\activate.bat
looks like:@echo off rem This file is UTF-8 encoded, so we need to update the current code page while executing it for /f "tokens=2 delims=:" %%a in ('"%SystemRoot%\System32\chcp.com"') do ( set "_OLD_CODEPAGE=%%a" ) if defined _OLD_CODEPAGE ( "%SystemRoot%\System32\chcp.com" 65001 > nul ) set "VIRTUAL_ENV=C:\Users\dacluc\env\" if not defined PROMPT ( set "PROMPT=$P$G" ) if defined _OLD_VIRTUAL_PROMPT ( set "PROMPT=%_OLD_VIRTUAL_PROMPT%" ) if defined _OLD_VIRTUAL_PYTHONHOME ( set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%" ) set "_OLD_VIRTUAL_PROMPT=%PROMPT%" set "PROMPT=() %PROMPT%" if defined PYTHONHOME ( set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%" set PYTHONHOME= ) if defined _OLD_VIRTUAL_PATH ( set "PATH=%_OLD_VIRTUAL_PATH%" ) else ( set "_OLD_VIRTUAL_PATH=%PATH%" ) set "PATH=%VIRTUAL_ENV%\Scripts;%PATH%" :END if defined _OLD_CODEPAGE ( "%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul set "_OLD_CODEPAGE=" )
Does it look good? Or does anything need to be modified?
Thanks a lot -
Can you tell me why you use conda for Python but then use the virtualenv module to create environments ?
It would be simpler to use conda directly for that as well.