简体   繁体   中英

PyCharm using Anaconda python.exe with Modules fails - ModuleNotFoundError: No module named 'PySide'

I'm trying to use Pycharm 2018.3 on Windows 10 with my Anaconda env (python.exe). It doesn't work, I don't know why.

The Project Interpreter is set to the python.exe correctly.

In VSC or Spyder and even in Jupyter Notebook, the code works. Only Pycharm doesn't find the modules.

This code:

print("Hello")
import sys
from qtpy import QtWidgets

gets this error message:

Hello
Traceback (most recent call last):
  File "D:\Python\Anaconda3\lib\site-packages\qtpy\__init__.py", line 199, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/PycharmProjects/ui/main.py", line 3, in <module>
    from qtpy import QtWidgets
  File "D:\Python\Anaconda3\lib\site-packages\qtpy\__init__.py", line 205, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

Process finished with exit code 1

I googled a lot of topics dealing with similar topics, but none solved the problem on my side.

Any ideas?

EDIT: Some additional information:

======================================== cmd.exe

C:\Users\Mega>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from qtpy import QtWidgets
Traceback (most recent call last):
  File "d:\Python\Anaconda3\lib\site-packages\qtpy\__init__.py", line 199, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "d:\Python\Anaconda3\lib\site-packages\qtpy\__init__.py", line 205, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found
>>>

====================================== Anaconda prompt

(base) C:\Users\Mega>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from qtpy import QtWidgets
>>>

====================================== Jupyter Notebook

in Jupyter Notebook this works

import sys
from qtpy import QtWidgets

app = QtWidgets.QApplication(sys.argv)

window = QtWidgets.QMainWindow()
window.setWindowTitle("HAAAAAAAAAAAAAAAAAAALLO")
window.show()

sys.exit(app.exec_())

and as I said in Visual Studio Code and Spyer it works too.

I have only one env in conda (base) C:\\Users\\Mega>conda env list

conda environments:

# base * D:\\Python\\Anaconda3

(base) C:\\Users\\Mega>

My pathes:

d:\Python\Anaconda3\python37.zip
d:\Python\Anaconda3\DLLs
d:\Python\Anaconda3\Lib
d:\Python\Anaconda3
d:\Python\Anaconda3\Lib\site-packages
d:\Python\Anaconda3\lib\site-packages\win32
d:\Python\Anaconda3\lib\site-packages\win32\lib
d:\Python\Anaconda3\lib\site-packages\pythonwin

I created a new env and tried that with PyCharm. Now, it is working. Sometimes, I don't know why and when, the default env of Anaconda doesn't work with Pycharm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM