[英]spyder3: “ModuleNotFoundError: No module named 'simplegeneric'”
I upgraded my Ubuntu 16.04 to 18.04. 我将Ubuntu 16.04升级到18.04。 Then I created a new virtual environment for Python and started spyder3:
然后,我为Python创建了一个新的虚拟环境并启动了spyder3:
python3 -m venv dev
source dev/bin/activate
spyder3
Then I got an error: 然后我得到一个错误:
...
ModuleNotFoundError: No module named 'simplegeneric'
So I had to do: 所以我必须做:
pip install wheel
pip install simplegeneric
But spyder3 still says that there is no module named 'simplegeneric'. 但是spyder3仍然说没有名为“简单通用”的模块。 Why?
为什么?
Some information about versions and installed modules: 有关版本和已安装模块的一些信息:
(dev) /media/shared/Development/python$ python3 -V
Python 3.6.5
(dev) /media/shared/Development/python$ pip -V
pip 9.0.1 from /media/shared/Development/python/dev/lib/python3.6/site-packages (python 3.6)
(dev) /media/shared/Development/python$ which spyder3
/media/shared/Development/python/dev/bin/spyder3
(dev) /media/shared/Development/python$ which pip
/media/shared/Development/python/dev/bin/pip
(dev) /media/shared/Development/python$ pip freeze | grep simplegeneric
simplegeneric==0.8.1
EDIT: 编辑:
My problem is not that I can't import simplegeneric within spyder. 我的问题不是我无法在spyder中导入simplegeneric。 My problem is that I cannot open spyder:
我的问题是我无法打开spyder:
(dev) /media/shared/Development/python$ spyder3
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 3126, in main
mainwindow = run_spyder(app, options, args)
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 3023, in run_spyder
main.setup()
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 932, in setup
from spyder.plugins.ipythonconsole import IPythonConsole
File "/usr/lib/python3/dist-packages/spyder/plugins/ipythonconsole.py", line 59, in <module>
from spyder.widgets.ipythonconsole import ClientWidget
File "/usr/lib/python3/dist-packages/spyder/widgets/ipythonconsole/__init__.py", line 12, in <module>
from .debugging import DebuggingWidget
File "/usr/lib/python3/dist-packages/spyder/widgets/ipythonconsole/debugging.py", line 16, in <module>
from qtconsole.rich_jupyter_widget import RichJupyterWidget
File "/usr/lib/python3/dist-packages/qtconsole/rich_jupyter_widget.py", line 14, in <module>
from .jupyter_widget import JupyterWidget
File "/usr/lib/python3/dist-packages/qtconsole/jupyter_widget.py", line 19, in <module>
from IPython.lib.lexers import IPythonLexer, IPython3Lexer
File "/usr/lib/python3/dist-packages/IPython/__init__.py", line 49, in <module>
from .terminal.embed import embed
File "/usr/lib/python3/dist-packages/IPython/terminal/embed.py", line 18, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/usr/lib/python3/dist-packages/IPython/terminal/interactiveshell.py", line 30, in <module>
from .debugger import TerminalPdb, Pdb
File "/usr/lib/python3/dist-packages/IPython/terminal/debugger.py", line 6, in <module>
from IPython.core.completer import IPCompleter
File "/usr/lib/python3/dist-packages/IPython/core/completer.py", line 34, in <module>
from IPython.utils import generics
File "/usr/lib/python3/dist-packages/IPython/utils/generics.py", line 8, in <module>
from simplegeneric import generic
ModuleNotFoundError: No module named 'simplegeneric'
EDIT 2: 编辑2:
It's obvious that I have the module 'simplegeneric' installed somewhere but spyder3 can't find it. 很明显,我在某个地方安装了模块“ simplegeneric”,但spyder3找不到它。 So I guess my problem is related to sys.path or $PYTHONPATH .
所以我想我的问题与sys.path或$ PYTHONPATH有关 。 That's my sys.path within the dev environment:
那是我在开发环境中的sys.path :
(dev) /media/shared/Development/python$ python3 -c "import sys; print('\n'.join(sys.path))"
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/media/shared/Development/python/dev/lib/python3.6/site-packages
And that's my regular sys.path : 这就是我的常规sys.path :
~$ python3 -c "import sys; print('\n'.join(sys.path))"
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
Shouldn't sys.path of my dev environment contain everything from the regular sys.path ? 开发环境的sys.path是否不应该包含常规sys.path中的所有内容?
I tried this, but it worked fine for me. 我试过了,但是对我来说很好。
C:\Users\RayanMadrid>pip install simplegeneric
Collecting simplegeneric
Downloading
https://files.pythonhosted.org/packages/3d/57/4d9c9e3ae9a255cd4e106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip
Installing collected packages: simplegeneric
Running setup.py install for simplegeneric ... done
Successfully installed simplegeneric-0.8.1
Then I ran it in Python: 然后我在Python中运行它:
>>> import simplegeneric
>>>
So your problem is something local to your machine. 因此,您的问题出在机器本地。
OK, finally I could solve my problem: pip3 was linked to a local copy and I think my local pip3 was messed up: 好的,最后我可以解决我的问题:pip3链接到本地副本,我认为我的本地pip3搞砸了:
~$ which pip3
/usr/local/bin/pip3
So I did: 所以我做了:
~$ sudo mv /usr/local/bin/pip3 pip3_bak
~$ which pip3
/usr/bin/pip3
Then I had to reinstall python3-simplegeneric: 然后我必须重新安装python3-simplegeneric:
~$ sudo apt-get install python3-simplegeneric --reinstall
Now I can start Spyder3 3.2.6 regularly or Spyder3 3.2.8 in my (dev) environment. 现在,我可以在(dev)环境中定期启动Spyder3 3.2.6或Spyder3 3.2.8。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.