Python3编译 错误 xcrun: error: invalid active developer path (LibraryDeveloperCommandLineTools) 解决

xiaoxiao2025-05-26  46

root@xubindeMBP:/usr/local/python3/Python-3.6.1# ./configure --prefix=/usr/local/python3 checking build system type... x86_64-apple-darwin18.0.0 checking host system type... x86_64-apple-darwin18.0.0 checking for python3.6... python3.6 checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... darwin checking for --without-gcc... no checking for --with-icc... no xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun checking for gcc... gcc checking whether the C compiler works... no configure: error: in `/usr/local/python3/Python-3.6.1': configure: error: C compiler cannot create executables See `config.log' for more details xubin@xubindeMBP:/usr/local/python3/Python-3.6.1$ brew reinstall python3 --with-brewed-openssl ==> Reinstalling python ==> Installing dependencies for python: pkg-config, sphinx-doc, gdbm, openssl, readline and sqlite ==> Installing python dependency: pkg-config xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Error: Failure while executing; `git config --local --replace-all homebrew.private true` exited with 1. xubin@xubindeMBP:/usr/local/python3/Python-3.6.1$ brew reinstall /usr/local/python3/Python-3.6.1 --with-brewed-openssl Error: No available formula with the name "/usr/local/python3/Python-3.6.1" xubin@xubindeMBP:/usr/local/python3/Python-3.6.1$ brew reinstall python3 --with-brewed-openssl ==> Reinstalling python ==> Installing dependencies for python: pkg-config, sphinx-doc, gdbm, openssl, readline and sqlite ==> Installing python dependency: pkg-config xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Error: Failure while executing; `git config --local --replace-all homebrew.private true` exited with 1.

我装的python3.6不能使用openssl所以想重新安装一下

我在重新编译python3的时候出错,通过百度跟交流群找到一些解决办法

特别感谢:https://stackoverflow.com/questions/32896524/invalid-active-developer-path-error-after-upgrading-to-el-capitan

第一步先更新mac的Xcode保证最新版本

第二步使用xcode-select --install命令安装一个软件如下:

安装之后重新编译一下发现没有在报错,到这里xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)的错误就算解决了。

xubin@xubindeMBP:/usr/local/python3/Python-3.6.1$ brew reinstall python3 --with-brewed-openssl ==> Reinstalling python ==> Installing dependencies for python: gdbm, openssl, readline and sqlite ==> Installing python dependency: gdbm ==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.mojave.bottle.tar.gz ######################################################################## 100.0% ==> Pouring gdbm-1.18.mojave.bottle.tar.gz ? /usr/local/Cellar/gdbm/1.18: 20 files, 588.7KB ==> Installing python dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2p.mojave.bottle.tar.gz ######################################################################## 100.0% ==> Pouring openssl-1.0.2p.mojave.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include" ==> Summary ? /usr/local/Cellar/openssl/1.0.2p: 1,793 files, 12MB ==> Installing python dependency: readline ==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.5.mojave.bottle.tar.gz ######################################################################## 100.0%

其他的都没问题不过在最后安装python的时候又报错了

==> Installing python ==> Downloading https://homebrew.bintray.com/bottles/python-3.7.0.mojave.bottle.6.tar.gz ######################################################################## 100.0% ==> Pouring python-3.7.0.mojave.bottle.6.tar.gz Error: An unexpected error occurred during the `brew link` step The formula built, but is not symlinked into /usr/local Permission denied @ dir_s_mkdir - /usr/local/Frameworks Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

错误:在“brew link”步骤中发生了意外错误 构建的公式,但没有符号连接到/usr/local 拒绝@ dir_s_mkdir - /usr/local/ framework的权限 错误:拒绝@ dir_s_mkdir - /usr/local/Frameworks权限

继续解决问题:

特别感谢:https://stackoverflow.com/questions/48908775/brew-install-python3-but-cant-link-to-python3

1:尝试创建Frameworks文件夹

sudo mkdir /usr/local/Frameworks

可以看到我们的文件已经存在了不过是root用户的

2:更改目录权限

sudo chown -R $(whoami) /usr/local/Frameworks

可以看到现在已经是这个用户的权限了

3:重新安装python3

xubin@xubindeMBP:/usr/local/python3$ brew reinstall python3 --with-brewed-openssl ==> Reinstalling python Warning: python: this formula has no --with-brewed-openssl option so it will be ignored! ==> Downloading https://homebrew.bintray.com/bottles/python-3.7.0.mojave.bottle.6.tar.gz Already downloaded: /Users/xubin/Library/Caches/Homebrew/downloads/58056bc7bf880926324af3cc7e406c39b31b2876b74c6bb150de7b9318273b2f--python-3.7.0.mojave.bottle.6.tar.gz ==> Pouring python-3.7.0.mojave.bottle.6.tar.gz ==> /usr/local/Cellar/python/3.7.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.0/bin --install-lib=/usr/local/lib/python3.7/site-packages --single ==> /usr/local/Cellar/python/3.7.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.0/bin --install-lib=/usr/local/lib/python3.7/site-packages --single ==> /usr/local/Cellar/python/3.7.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.0/bin --install-lib=/usr/local/lib/python3.7/site-packages --single ==> Caveats Python has been installed as /usr/local/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /usr/local/opt/python/libexec/bin If you need Homebrew's Python 2.7 run brew install python@2 Pip, setuptools, and wheel have been installed. To update them run pip3 install --upgrade pip setuptools wheel You can install Python packages with pip3 install <package> They will install into the site-package directory /usr/local/lib/python3.7/site-packages See: https://docs.brew.sh/Homebrew-and-Python ==> Summary ? /usr/local/Cellar/python/3.7.0: 4,781 files, 102MB

4:我们查看一下

xubin@xubindeMBP:~$ python python python2.7 python3 python3.6 python3.6m python3.7 python3.7m pythonw python-config python2.7-config python3-config python3.6-config python3.6m-config python3.7-config python3.7m-config pythonw2.7

发现有好多的python,刚刚最新安装的是3.7 进去看一下

先看一下3.6,进入3.6加载ssl模块发现报错,这也是我重装的原因

xubin@xubindeMBP:~$ python3.6 Python 3.6.0 (default, Jun 19 2018, 13:24:21) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import ssl Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/etc/python/python3.6/lib/python3.6/ssl.py", line 101, in <module> import _ssl # if we can't import it, let the error propagate ModuleNotFoundError: No module named '_ssl' >>> exit();

然后看一下刚刚编译安装的3.7版本的,是可以加载ssl模块的

xubin@xubindeMBP:~$ python3.7 Python 3.7.0 (default, Oct 2 2018, 09:18:58) [Clang 10.0.0 (clang-1000.11.45.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import ssl >>> exit();

总结:在编译python的时候要带参数brew reinstall python3 --with-brewed-openssl

 

转载请注明原文地址: https://www.6miu.com/read-5030740.html

最新回复(0)