spyder3:“ModuleNotFoundError:没有名为'simplegeneric'的模块”

时间:2018-05-06 11:26:26

标签: python python-3.6 spyder

我将Ubuntu 16.04升级到18.04。然后我为Python创建了一个新的虚拟环境并启动了spyder3:

python3 -m venv dev
source dev/bin/activate
spyder3

然后我收到了一个错误:

...
ModuleNotFoundError: No module named 'simplegeneric'

所以我必须这样做:

pip install wheel
pip install simplegeneric

但是spyder3仍然说没有名为'simplegeneric'的模块。为什么呢?

有关版本和已安装模块的一些信息:

(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

编辑:

我的问题不在于我无法在spyder中导入simplegeneric。我的问题是我无法打开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'

编辑2:

很明显,我在某处安装了模块'simplegeneric',但是spyder3无法找到它。所以我猜我的问题与 sys.path $ PYTHONPATH 有关。 那是开发环境中的 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

这是我的常规 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

我的开发环境的 sys.path 是否应包含常规 sys.path 中的所有内容?

2 个答案:

答案 0 :(得分:2)

我尝试了这个,但它对我来说很好。

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

然后我用Python运行它:

>>> import simplegeneric
>>>

所以你的问题是你机器的本地问题。

答案 1 :(得分:0)

好的,最后我可以解决我的问题: pip3链接到本地​​副本,我认为我的本地pip3搞砸了:

alter table SOMETHING add constraint CKC_HAHA_SOMETHING check (HAHA < (to_number(to_char(sysdate, 'YYYY'))));
alter table SOMETHING add constraint CKC_HAHA_SOMETHING check (HAHA < extract(YEAR from sysdate));

所以我做了:

~$ which pip3
/usr/local/bin/pip3

然后我不得不重新安装python3-simplegeneric:

~$ sudo mv /usr/local/bin/pip3 pip3_bak
~$ which pip3
/usr/bin/pip3

现在我可以在我的(开发)环境中定期启动Spyder3 3.2.6或Spyder3 3.2.8。