pip安装pymoo失败,报ModuleNotFoundError错误求解决方案
问题描述
执行pip install -U pymoo安装pymoo失败,已更新pip但问题未解决,C:\Program Files\Spyder\Python\Scripts已添加到系统PATH。报错信息如下:
C:\Program Files\Spyder\Python\Scripts>pip install -U pymoo Collecting pymoo Using cached pymoo-0.6.1.2.tar.gz (1.3 MB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\AvdKAdmin\AppData\Local\Temp\pip-install-7pe_9kfn\pymoo_b3604a5d5c0444c584d6f0acf707f036\setup.py", line 11, in <module> from pymoo.version import __version__ ModuleNotFoundError: No module named 'pymoo' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. C:\Program Files\Spyder\Python\Scripts>
已安装包列表:
C:\Program Files\Spyder\Python\Scripts>pip list Package Version ----------------------------- -------------- alabaster 0.7.13 arrow 1.3.0 astroid 3.2.2 asttokens 2.4.1 atomicwrites 1.4.1 attrs 23.2.0 autopep8 2.0.4 Babel 2.15.0 backcall 0.2.0 backports.tarfile 1.2.0 beautifulsoup4 4.12.3 binaryornot 0.4.4 black 24.4.2 bleach 6.1.0 blinker 1.8.2 certifi 2024.6.2 cffi 1.16.0 chardet 5.2.0 charset-normalizer 3.3.2 click 8.1.7 cloudpickle 3.0.0 colorama 0.4.6 comm 0.2.2 contourpy 1.1.1 cookiecutter 2.6.0 cryptography 42.0.8 cycler 0.12.1 Cython 3.0.10 debugpy 1.8.1 decorator 5.1.1 defusedxml 0.7.1 diff-match-patch 20230430 dill 0.3.8 docstring-to-markdown 0.15 docutils 0.20.1 et-xmlfile 1.1.0 executing 2.0.1 ez_setup 0.9 fastjsonschema 2.19.1 flake8 7.0.0 Flask 3.0.3 Flask-MySQLdb 2.0.0 fonttools 4.53.0 idna 3.7 imagesize 1.4.1 importlib_metadata 7.1.0 importlib_resources 6.4.0 inflection 0.5.1 intervaltree 3.1.0 ipykernel 6.29.4 ipython 8.12.3 isort 5.13.2 itsdangerous 2.2.0 jaraco.classes 3.4.0 jaraco.context 5.3.0 jaraco.functools 4.0.1 jedi 0.19.1 jellyfish 1.0.4 Jinja2 3.1.4 jsonschema 4.22.0 jsonschema-specifications 2023.12.1 jupyter_client 8.6.2 jupyter_core 5.7.2 jupyterlab_pygments 0.3.0 keyring 25.2.1 kiwisolver 1.4.5 markdown-it-py 3.0.0 MarkupSafe 2.1.5 matplotlib 3.7.5 matplotlib-inline 0.1.7 mccabe 0.7.0 mdurl 0.1.2 mistune 3.0.2 more-itertools 10.3.0 mpmath 1.3.0 mypy-extensions 1.0.0 mysqlclient 2.2.4 nbclient 0.10.0 nbconvert 7.16.4 nbformat 5.10.4 nest-asyncio 1.6.0 networkx 3.1 numpy 1.24.4 numpydoc 1.7.0 openpyxl 3.1.3 packaging 24.1 pandas 2.0.3 pandocfilters 1.5.1 paramiko 3.4.0 parso 0.8.4 pathspec 0.12.1 pexpect 4.9.0 pickleshare 0.7.5 pillow 10.3.0 pip 24.2 pkgutil_resolve_name 1.3.10 platformdirs 4.2.2 pluggy 1.5.0 prompt_toolkit 3.0.47 psutil 6.0.0 ptyprocess 0.7.0 pure-eval 0.2.2 pycodestyle 2.11.1 pycparser 2.22 pydocstyle 6.3.0 pyflakes 3.2.0 Pygments 2.18.0 pylint 3.2.3 pylint-venv 3.0.3 pyls-spyder 0.4.0 pyparsing 3.1.2 PyQt5 5.15.10 PyQt5-Qt5 5.15.2 PyQt5-sip 12.13.0 PyQtWebEngine 5.15.6 PyQtWebEngine-Qt5 5.15.2 python-dateutil 2.9.0.post0 python-lsp-black 2.0.0 python-lsp-jsonrpc 1.1.2 python-lsp-server 1.11.0 pytoolconfig 1.3.1 pytz 2024.1 pywin32 306 pywin32-ctypes 0.2.2 pyxdg 0.28 PyYAML 6.0.1 pyzmq 26.0.3 QDarkStyle 3.2.3 qstylizer 0.2.3 QtAwesome 1.3.1 qtconsole 5.5.2 QtPy 2.4.1 referencing 0.35.1 requests 2.32.3 rich 13.7.1 rope 1.13.0 rpds-py 0.18.1 Rtree 1.3.0 scipy 1.10.1 setuptools 73.0.1 six 1.16.0 snowballstemmer 2.2.0 sortedcontainers 2.4.0 soupsieve 2.5 Sphinx 7.1.2 sphinxcontrib-applehelp 1.0.4 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 2.0.1 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.5 spyder 5.5.5 spyder-kernels 2.5.2 stack-data 0.6.3 sympy 1.12.1 tabulate 0.9.0 text-unidecode 1.3 textdistance 4.6.2 three-merge 0.1.1 tinycss2 1.3.0 tomli 2.0.1 tomlkit 0.12.5 tornado 6.4.1 traitlets 5.14.3 types-python-dateutil 2.9.0.20240316 typing_extensions 4.12.2 tzdata 2024.1 ujson 5.10.0 urllib3 2.2.1 watchdog 4.0.1 wcwidth 0.2.13 webencodings 0.5.1 Werkzeug 3.0.3 whatthepatch 1.0.5 wheel 0.43.0 yapf 0.40.2 zipp 3.19.2 C:\Program Files\Spyder\Python\Scripts>
解决建议
这个报错是因为pymoo 0.6.1.2的源码包在生成metadata时,setup.py尝试导入未安装的pymoo模块导致的,试试以下几种方法:
方法1:安装预编译wheel包
直接指定安装wheel版本,避免从源码编译:pip install pymoo --only-binary :all:方法2:安装更新版本的pymoo
0.6.1.2之后的版本可能修复了setup.py的问题,尝试安装最新版:# 安装指定修复版本 pip install pymoo==0.6.2 # 或者直接安装最新版并清除缓存 pip install pymoo --upgrade --no-cache-dir方法3:降级setuptools
你的setuptools版本较新,可能和旧版pymoo的setup.py不兼容,试试降级到稳定版本:pip install setuptools==65.5.0 pip install -U pymoo方法4:手动下载并安装
- 下载对应你Python版本的pymoo wheel包(比如适配Python 3.10的
pymoo-0.6.1.2-cp310-cp310-win_amd64.whl) - 执行本地安装:
pip install 你的wheel文件路径\pymoo-wheel-file.whl- 下载对应你Python版本的pymoo wheel包(比如适配Python 3.10的
内容的提问来源于stack exchange,提问作者Alex van der Kooi
相关产品推荐
相关产品推荐

