在Mac OS X上使用pip无法安装simpleaudio

4
每当我尝试在终端中运行命令pip install simpleaudio时,它返回以下内容:
Collecting simpleaudio
  Using cached simpleaudio-1.0.1.tar.gz
     Complete output from command python setup.py egg_info:
     Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-build-3N7xxl/simpleaudio/setup.py", line 40, in <module>
        encoding='utf-8') as f:
     TypeError: 'encoding' is an invalid keyword argument for this function

     ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-build-3N7xxl/simpleaudio/

如果我尝试使用 python3 -m pip install simpleaudio 安装它,我会得到以下输出:

Collecting simpleaudio
  Using cached simpleaudio-1.0.1.tar.gz
Installing collected packages: simpleaudio
  Running setup.py install for simpleaudio ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-build-1201y9fs/simpleaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-yguvrnt6-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.6
    creating build/lib.macosx-10.6-intel-3.6/simpleaudio
    copying simpleaudio/__init__.py -> build/lib.macosx-10.6-intel-3.6/simpleaudio
    copying simpleaudio/shiny.py -> build/lib.macosx-10.6-intel-3.6/simpleaudio
    copying simpleaudio/functionchecks.py -> build/lib.macosx-10.6-intel-3.6/simpleaudio
    creating build/lib.macosx-10.6-intel-3.6/simpleaudio/test_audio
    copying simpleaudio/test_audio/c.wav -> build/lib.macosx-10.6-intel-3.6/simpleaudio/test_audio
    copying simpleaudio/test_audio/e.wav -> build/lib.macosx-10.6-intel-3.6/simpleaudio/test_audio
    copying simpleaudio/test_audio/g.wav -> build/lib.macosx-10.6-intel-3.6/simpleaudio/test_audio
    copying simpleaudio/test_audio/left_right.wav -> build/lib.macosx-10.6-intel-3.6/simpleaudio/test_audio
    copying simpleaudio/test_audio/notes_2_16_44.wav -> build/lib.macosx-10.6-intel-3.6/simpleaudio/test_audio
    running build_ext
    building 'simpleaudio._simpleaudio' extension
    creating build/temp.macosx-10.6-intel-3.6
    creating build/temp.macosx-10.6-intel-3.6/c_src
    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -DDEBUG=0 -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c c_src/simpleaudio_mac.c -o build/temp.macosx-10.6-intel-3.6/c_src/simpleaudio_mac.o -mmacosx-version-min=10.6
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    error: command '/usr/bin/clang' failed with exit status 1

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-build-1201y9fs/simpleaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-yguvrnt6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/rm/1wlhdbc15tq591by9qnr4_180000gn/T/pip-build-1201y9fs/simpleaudio/

我的Python版本是

Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]

我该如何在此Python解释器中安装simpleaudio?

1
这看起来像是 Python 3 / Python 2 不兼容的问题。你的 Mac 上安装了 Python 3 吗?如果有,你是否使用了正确版本的 pip? - PM 2Ring
我正在使用Python 3,因为这是simpleaudio运行所需的 - 至少从他们的网站上我所了解到的。 - Zonear
我猜你正在做这样的事情:pip install simpleaudio。相反,试试这个:python3 -m pip install simpleaudio - PM 2Ring
我使用Linux而不是Mac,所以我不确定您需要做什么才能正确安装。在Linux上,您必须以root用户模式执行此操作(即使用sudo)或安装到虚拟环境中。理想情况下,您也应该在Mac上安装到虚拟环境中,例如使用Anaconda,但您需要从Mac用户那里获取更多详细信息的帮助。 ;) - PM 2Ring
@PM2Ring 当使用 python3 -m pip install simpleaudio 时,仍然返回错误。 - Zonear
显示剩余11条评论
1个回答

0

@Zonear的链接说要...

禁用“系统完整性保护”,这样root用户就可以修改Mac上的所有文件:

Boot into recovery mode (hold [Command]+R during reboot)
In Terminal (from dropdown menu) run `csrutil disable`
Reboot

修复 /usr/local 的权限:

sudo chflags norestricted /usr/local
sudo chown $(whoami):admin /usr/local
sudo chown -R $(whoami):admin /usr/local

重新安装Xcode开发工具:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

检查Homebrew并按医生的指示操作:

brew update
brew doctor

升级所有已安装的brew软件包:

brew upgrade

如果 git --version 提到了 "Apple Git",你需要摆脱它:
sudo mv /usr/bin/git /usr/bin/git.xcode
sudo ln -s /usr/local/git/bin/git /usr/bin/git

下载并重新安装 gpgtools

买一个 Linux 笔记本电脑!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接