安装playsound时如何修复“OSError:无法获取源代码”错误?

bei*_*433 9 python python-playsound

    Collecting playsound\n      Using cached playsound-1.3.0.tar.gz (7.7 kB)\n      Installing build dependencies ... done\n      Getting requirements to build wheel ... error\n      error: subprocess-exited-with-error\n\n      \xc3\x97 Getting requirements to build wheel did not run successfully.\n      \xe2\x94\x82 exit code: 1\n      \xe2\x95\xb0\xe2\x94\x80> [29 lines of output]\n          Traceback (most recent call last):\n            File "C:\\Users\\INTEL\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py", line 353, in <module>\n              main()\n            File "C:\\Users\\INTEL\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py", line 335, in main\n              json_out[\'return_val\'] = hook(**hook_input[\'kwargs\'])\n                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n            File "C:\\Users\\INTEL\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py", line 118, in get_requires_for_build_wheel\n              return hook(config_settings)\n                     ^^^^^^^^^^^^^^^^^^^^^\n            File "C:\\Users\\INTEL\\AppData\\Local\\Temp\\pip-build-env-9ac5eef9\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py", line 341, in get_requires_for_build_wheel\n              return self._get_build_requires(config_settings, requirements=[\'wheel\'])\n                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n            File "C:\\Users\\INTEL\\AppData\\Local\\Temp\\pip-build-env-9ac5eef9\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py", line 323, in _get_build_requires \n              self.run_setup()\n            File "C:\\Users\\INTEL\\AppData\\Local\\Temp\\pip-build-env-9ac5eef9\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py", line 488, in run_setup\n              self).run_setup(setup_script=setup_script)\n                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n            File "C:\\Users\\INTEL\\AppData\\Local\\Temp\\pip-build-env-9ac5eef9\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py", line 338, in run_setup\n              exec(code, locals())\n            File "<string>", line 6, in <module>\n            File "C:\\Users\\INTEL\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\inspect.py", line 1270, in getsource\n              lines, lnum = getsourcelines(object)\n                            ^^^^^^^^^^^^^^^^^^^^^^\n            File "C:\\Users\\INTEL\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\inspect.py", line 1252, in getsourcelines\n              lines, lnum = findsource(object)\n                            ^^^^^^^^^^^^^^^^^^\n            File "C:\\Users\\INTEL\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\inspect.py", line 1081, in findsource\n              raise OSError(\'could not get source code\')\n          OSError: could not get source code\n          [end of output]\n    \n  note: This error originates from a subprocess, and is likely not a     problem with pip.\n\n    error: subprocess-exited-with-error\n\n    \xc3\x97 Getting requirements to build wheel did not run successfully.\n    \xe2\x94\x82 exit code: 1\n    \xe2\x95\xb0\xe2\x94\x80> See above for output.\n\nnote: This error originates from a subprocess, and is likely not a problem with pip.\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试更新Python版本和pip版本。

\n

小智 16

这可以解决这个问题:

pip install --upgrade wheel
Run Code Online (Sandbox Code Playgroud)


hel*_*llo 5

尝试跑步

pip install --upgrade wheel
Run Code Online (Sandbox Code Playgroud)


小智 1

看起来您正在运行python 3.11Playsound 1.3.0目前最高支持python 3.9尝试降级或使用像Anaconda这样的 venv以获得多个可用的 python 版本。