`pip wxpython`引发`ModuleNotFoundError: No module named ‘attrdict’`错误。

huangapple go评论133阅读模式
英文:

pip wxpython gives ModuleNotFoundError: No module named 'attrdict'

问题

使用pip安装wxpython时出现错误 ModuleNotFoundError: No module named 'attrdict'

详细信息:

  1. py -3.10-64 -m pip install -U wxpython
  2. Collecting wxpython
  3. Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  4. Preparing metadata (setup.py) ... error
  5. error: subprocess-exited-with-error
  6. × python setup.py egg_info did not run successfully.
  7. exit code: 1
  8. ╰─> [8 lines of output]
  9. Traceback (most recent call last):
  10. File "<string>", line 2, in <module>
  11. File "<pip-setuptools-caller>", line 34, in <module>
  12. File "C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\setup.py", line 27, in <module>
  13. from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
  14. File "C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\buildtools\config.py", line 30, in <module>
  15. from attrdict import AttrDict
  16. ModuleNotFoundError: No module named 'attrdict'
  17. [end of output]
  18. note: This error originates from a subprocess, and is likely not a problem with pip.
  19. error: metadata-generation-failed
  20. × Encountered error while generating package metadata.
  21. ╰─> See above for output.
  22. note: This is an issue with the package mentioned above, not pip.
  23. hint: See above for details.

已经生效的解决方案

安装其他包可以正常工作,例如:

  1. py -3.10-64 -m pip install -U mido
  2. Requirement already satisfied: mido in c:\python311\lib\site-packages (1.2.10)

版本信息

Windows 10 22H2
pip 23.0.1 from C:\Python311\Lib\site-packages\pip (python 3.11)

背景

这是在fluidpatcher安装程序中使用的,我在这里记录了一个错误。

更新 1

似乎这是一个已知的问题,已在这里报告。

尝试手动安装的解决方法:

  1. py -3.10-64 -m pip install -U attrdict3

然后再次尝试安装wxpython:

  1. py -3.10-64 -m pip install -U wxpython

但是这次会出现不同的错误消息。

更新 2

解决方法:安装Python 3.10。

英文:

Installing wxpython with pip gives the error ModuleNotFoundError: No module named &#39;attrdict&#39;

Details:

py -3.10-64 -m pip install -U wxpython

  1. Collecting wxpython
  2. Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  3. Preparing metadata (setup.py) ... error
  4. error: subprocess-exited-with-error
  5. &#215; python setup.py egg_info did not run successfully.
  6. exit code: 1
  7. ╰─&gt; [8 lines of output]
  8. Traceback (most recent call last):
  9. File &quot;&lt;string&gt;&quot;, line 2, in &lt;module&gt;
  10. File &quot;&lt;pip-setuptools-caller&gt;&quot;, line 34, in &lt;module&gt;
  11. File &quot;C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\setup.py&quot;, line 27, in &lt;module&gt;
  12. from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
  13. File &quot;C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\buildtools\config.py&quot;, line 30, in &lt;module&gt;
  14. from attrdict import AttrDict
  15. ModuleNotFoundError: No module named &#39;attrdict&#39;
  16. [end of output]
  17. note: This error originates from a subprocess, and is likely not a problem with pip.
  18. error: metadata-generation-failed
  19. &#215; Encountered error while generating package metadata.
  20. ╰─&gt; See above for output.
  21. note: This is an issue with the package mentioned above, not pip.
  22. hint: See above for details.

What works

installing other packages works, e.g.

py -3.10-64 -m pip install -U mido
Requirement already satisfied: mido in c:\python311\lib\site-packages (1.2.10)

Version info

Windows 10 22H2
pip 23.0.1 from C:\Python311\Lib\site-packages\pip (python 3.11)

Context

This is used in the fluidpatcher installer, I logged a bug here.

Update 1

Seems to be a known issue reported here: https://github.com/wxWidgets/Phoenix/issues/2296

Tried workaround of manually installing

  1. py -3.10-64 -m pip install -U attrdict3

Which installs.

Then retried the wxpython install

  1. py -3.10-64 -m pip install -U wxpython

Which fails, this time with a different error message

  1. Collecting wxpython
  2. Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  3. Preparing metadata (setup.py) ... done
  4. Requirement already satisfied: pillow in c:\python311\lib\site-packages (from wxpython) (9.4.0)
  5. Requirement already satisfied: six in c:\python311\lib\site-packages (from wxpython) (1.16.0)
  6. Requirement already satisfied: numpy in c:\python311\lib\site-packages (from wxpython) (1.24.2)
  7. Installing collected packages: wxpython
  8. DEPRECATION: wxpython is being installed using the legacy &#39;setup.py install&#39; method, because it does not have a &#39;pyproject.toml&#39; and the &#39;wheel&#39; package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the &#39;--use-pep517&#39; option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  9. Running setup.py install for wxpython ... error
  10. error: subprocess-exited-with-error
  11. &#215; Running setup.py install for wxpython did not run successfully.
  12. exit code: 1
  13. ╰─&gt; [49 lines of output]
  14. C:\Python311\Lib\site-packages\setuptools\dist.py:771: UserWarning: Usage of dash-separated &#39;license-file&#39; will not be supported in future versions. Please use the underscore name &#39;license_file&#39; instead
  15. warnings.warn(
  16. C:\Python311\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
  17. warnings.warn(msg, warning_class)
  18. C:\Python311\Lib\site-packages\setuptools\dist.py:317: DistDeprecationWarning: use_2to3 is ignored.
  19. warnings.warn(f&quot;{attr} is ignored.&quot;, DistDeprecationWarning)
  20. running install
  21. C:\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  22. warnings.warn(
  23. running build
  24. Will build using: &quot;C:\Python311\python.exe&quot;
  25. 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
  26. Python&#39;s architecture is 64bit
  27. cfg.VERSION: 4.2.0
  28. Running command: build
  29. Running command: build_wx
  30. Command &#39;&quot;C:\Python311\python.exe&quot; -c &quot;import os, sys, setuptools.msvc; setuptools.msvc.isfile = lambda path: path is not None and os.path.isfile(path); ei = setuptools.msvc.EnvironmentInfo(&#39;x64&#39;, vc_min_ver=14.0); env = ei.return_env(); env[&#39;vc_ver&#39;] = ei.vc_ver; env[&#39;vs_ver&#39;] = ei.vs_ver; env[&#39;arch&#39;] = ei.pi.arch; env[&#39;py_ver&#39;] = sys.version_info[:2]; print(env)&quot;&#39; failed with exit code 1.
  31. Traceback (most recent call last):
  32. File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  33. File &quot;C:\Python311\Lib\site-packages\setuptools\msvc.py&quot;, line 1120, in __init__
  34. self.si = SystemInfo(self.ri, vc_ver)
  35. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  36. File &quot;C:\Python311\Lib\site-packages\setuptools\msvc.py&quot;, line 596, in __init__
  37. vc_ver or self._find_latest_available_vs_ver())
  38. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  39. File &quot;C:\Python311\Lib\site-packages\setuptools\msvc.py&quot;, line 610, in _find_latest_available_vs_ver
  40. raise distutils.errors.DistutilsPlatformError(
  41. distutils.errors.DistutilsPlatformError: No Microsoft Visual C++ version found
  42. Finished command: build_wx (0m1.80s)
  43. Finished command: build (0m1.80s)
  44. WARNING: Building this way assumes that all generated files have been
  45. generated already. If that is not the case then use build.py directly
  46. to generate the source and perform the build stage. You can use
  47. --skip-build with the bdist_* or install commands to avoid this
  48. message and the wxWidgets and Phoenix build steps in the future.
  49. &quot;C:\Python311\python.exe&quot; -u build.py build
  50. Command &#39;&quot;C:\Python311\python.exe&quot; -u build.py build&#39; failed with exit code 1.
  51. [end of output]
  52. note: This error originates from a subprocess, and is likely not a problem with pip.
  53. error: legacy-install-failure
  54. &#215; Encountered error while trying to install package.
  55. ╰─&gt; wxpython

Update 2

Workaround: install Python 3.10.

答案1

得分: 3

对于仍然感兴趣的人:我已成功在Windows上,在WinPython 3.11.1(从SouceForge获取)下安装了wxPython,方法如下:

  1. pip install -U attrdict3
  2. pip install wxpython

安装完成后,在\Lib\site-packages\wx目录中,您需要手动将所有没有扩展名的文件重命名,以便它们具有.pyd扩展名。

英文:

For those who are still interested: I have successfully installed wxPython on Windows, under WinPython 3.11.1 (got it from SouceForge) with:

  1. pip install -U attrdict3
  2. pip install wxpython

After installation, in the \Lib\site-packages\wx dir, you have to rename all files with no extension manually so they have the .pyd extension.

huangapple
  • 本文由 发表于 2023年2月19日 20:57:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500303.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定