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

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

pip wxpython gives ModuleNotFoundError: No module named 'attrdict'

问题

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

详细信息:

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

    Collecting wxpython
      Using cached wxPython-4.2.0.tar.gz (71.0 MB)
      Preparing metadata (setup.py) ... error
      error: subprocess-exited-with-error
    
      × python setup.py egg_info did not run successfully.
      │ exit code: 1
      ╰─> [8 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\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\setup.py", line 27, in <module>
              from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
            File "C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\buildtools\config.py", line 30, in <module>
              from attrdict import AttrDict
          ModuleNotFoundError: No module named 'attrdict'
          [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.

已经生效的解决方案

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

py -3.10-64 -m pip install -U mido
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

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

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

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

然后再次尝试安装wxpython:

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

Collecting wxpython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  &#215; python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─&gt; [8 lines of output]
      Traceback (most recent call last):
        File &quot;&lt;string&gt;&quot;, line 2, in &lt;module&gt;
        File &quot;&lt;pip-setuptools-caller&gt;&quot;, line 34, in &lt;module&gt;
        File &quot;C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\setup.py&quot;, line 27, in &lt;module&gt;
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File &quot;C:\Users\Bernard\AppData\Local\Temp\pip-install-dokcizpt\wxpython_662eefb4314c47eba7b194b4d07a8e18\buildtools\config.py&quot;, line 30, in &lt;module&gt;
          from attrdict import AttrDict
      ModuleNotFoundError: No module named &#39;attrdict&#39;
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

&#215; Encountered error while generating package metadata.
╰─&gt; See above for output.

note: This is an issue with the package mentioned above, not pip.
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

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

Which installs.

Then retried the wxpython install

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

Which fails, this time with a different error message

Collecting wxpython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in c:\python311\lib\site-packages (from wxpython) (9.4.0)
Requirement already satisfied: six in c:\python311\lib\site-packages (from wxpython) (1.16.0)
Requirement already satisfied: numpy in c:\python311\lib\site-packages (from wxpython) (1.24.2)
Installing collected packages: wxpython
  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
  Running setup.py install for wxpython ... error
  error: subprocess-exited-with-error

  &#215; Running setup.py install for wxpython did not run successfully.
  │ exit code: 1
  ╰─&gt; [49 lines of output]
      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
        warnings.warn(
      C:\Python311\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      C:\Python311\Lib\site-packages\setuptools\dist.py:317: DistDeprecationWarning: use_2to3 is ignored.
        warnings.warn(f&quot;{attr} is ignored.&quot;, DistDeprecationWarning)
      running install
      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.
        warnings.warn(
      running build
      Will build using: &quot;C:\Python311\python.exe&quot;
      3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
      Python&#39;s architecture is 64bit
      cfg.VERSION: 4.2.0

      Running command: build
      Running command: build_wx
      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.
      Traceback (most recent call last):

        File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;

        File &quot;C:\Python311\Lib\site-packages\setuptools\msvc.py&quot;, line 1120, in __init__

          self.si = SystemInfo(self.ri, vc_ver)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^

        File &quot;C:\Python311\Lib\site-packages\setuptools\msvc.py&quot;, line 596, in __init__

          vc_ver or self._find_latest_available_vs_ver())

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        File &quot;C:\Python311\Lib\site-packages\setuptools\msvc.py&quot;, line 610, in _find_latest_available_vs_ver

          raise distutils.errors.DistutilsPlatformError(

      distutils.errors.DistutilsPlatformError: No Microsoft Visual C++ version found
      Finished command: build_wx (0m1.80s)
      Finished command: build (0m1.80s)
      WARNING: Building this way assumes that all generated files have been
      generated already.  If that is not the case then use build.py directly
      to generate the source and perform the build stage.  You can use
      --skip-build with the bdist_* or install commands to avoid this
      message and the wxWidgets and Phoenix build steps in the future.

      &quot;C:\Python311\python.exe&quot; -u build.py build
      Command &#39;&quot;C:\Python311\python.exe&quot; -u build.py build&#39; failed with exit code 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

&#215; Encountered error while trying to install package.
╰─&gt; wxpython

Update 2

Workaround: install Python 3.10.

答案1

得分: 3

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

pip install -U attrdict3
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:

pip install -U attrdict3
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:

确定