我正在尝试将Windows 10上的Pycharm 2018.3与我的Anaconda env(python.exe)一起使用。 它不起作用,我不知道为什么。
项目解释器已正确设置为python.exe。
在VSC或Spyder中,甚至在Jupyter Notebook中,代码都可以工作。 只有Pycharm找不到模块。
此代码:
print("Hello")
import sys
from qtpy import QtWidgets
获取此错误消息:
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
我搜索了很多涉及相似主题的主题,但没有一个能解决我的问题。
有什么想法吗?
编辑:一些其他信息:
======================================= 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提示
(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
在Jupyter Notebook中有效
import sys
from qtpy import QtWidgets
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
window.setWindowTitle("HAAAAAAAAAAAAAAAAAAALLO")
window.show()
sys.exit(app.exec_())
正如我在Visual Studio Code和Spyer中所说的那样,它也可以工作。
我在conda中只有一个环境 (基本)C:\ Users \ Mega> conda环境列表
# 基本* D:\ Python \ Anaconda3
(基本)C:\ Users \ Mega>
我的路径:
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
答案 0 :(得分:0)
我创建了一个新的环境,并使用PyCharm进行了尝试。现在,它正在工作。有时,我不知道为什么和何时,Anaconda的默认环境不适用于Pycharm。