我的Anaconda发行版表现得很奇怪。我最初的目的是导入Signal或pyqtSignal。这是在 Spyder的IPython控制台中发生的事情:
Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 6.4.0 -- An enhanced Interactive Python.
In [1]: from PyQt5.QtCore import Signal
In [2]: from PyQt5.QtCore import pyqtSignal
In [3]: import PyQt5.QtCore
...: PyQt5.QtCore.__file__
Out[3]: 'C:\\Users\\blah\\Anaconda3\\lib\\site-packages\\PyQt5\\QtCore.pyd'
但是,当我打开Anaconda提示符(相同的环境)时,键入“ ipython”和与上面相同的代码,我得到:
Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from PyQt5.QtCore import Signal
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-90eb87fde834> in <module>()
----> 1 from PyQt5.QtCore import Signal
ImportError: cannot import name 'Signal'
In [2]: from PyQt5.QtCore import pyqtSignal
In [3]: import PyQt5.QtCore
...: PyQt5.QtCore.__file__
...:
...:
Out[3]: 'C:\\Users\\blah\\Anaconda3\\lib\\site-packages\\PyQt5\\QtCore.pyd'
在这种情况下,Signal
导入会失败,尽管库是相同的。
是什么原因导致Spyder的IPython控制台与“常规” IPython控制台之间出现这种不一致的行为?
PyQt5版本:5.9.2:
(base) C:\Users\blah>conda list -f pyqt
# packages in environment at C:\Users\blah\Anaconda3:
#
# Name Version Build Channel
pyqt 5.9.2 py36h6538335_2