https://github.com/famousdraw

苹果系统无法正确连接python到python3

Developer Forums
 
 
 

MAC建立python软连接,不生效
sudo ln -s /usr/bin/python3 /usr/local/bin/python
jason_zhao@192 bin % python
xcode-select: Failed to locate 'python', requesting installation of command line developer tools.

首先取消原有的软连接:
sudo unlink /usr/local/bin/python

然后继续看如下文章
https://developer.apple.com/forums/thread/704099
 
 
 

prompt keeps popping up asking me to install the command line developer tools

After installing xcode13.3, a prompt keeps popping up asking me to install the command line developer tools, but I have already installed it, and this prompt keeps popping up, what should I do?

Post not yet marked as solved Up vote post of horry Down vote post of horry
17k views
 
  • // xcode-select --install ? i enter this xcode-select: error: command line tools are already installed, use "Software Update" to install updates // got this

    but this system always tell me: python: error: Failed to locate 'python'. xcode-select: Failed to locate 'python', requesting installation of command line developer tools.

    1 year ago
Add a Comment

Replies

The python command was traditionally an alias for Python 2.x, which is no longer available. If you want to use the built-in Python 3, invoke it with python3. However, in most cases it’s best to install your own Python because Apple’s built-in copies have been deprecated. You can learn more about this in the Scripting Language Runtimes section of the macOS Catalina 10.15 Release Notes.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I am running into the same problem and cannot find a solution. This is what I see (note the developer command line tools are installed)

$ python
xcode-select: Failed to locate 'python', requesting installation of command line developer tools.
$ python3
Python 3.8.9 (default, Jul 19 2021, 09:37:32)
[Clang 13.0.0 (clang-1300.0.27.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ ln -s /usr/bin/python3 /usr/local/bin/python
$ which python
/usr/local/bin/python
$ python
xcode-select: Failed to locate 'python', requesting installation of command line developer tools.
$ /usr/local/bin/python
xcode-select: Failed to locate 'python', requesting installation of command line developer tools.
$ /usr/bin/env python
xcode-select: Failed to locate 'python', requesting installation of command line developer tools.

If I put another python on my PATH (outside of /usr/bin and /usr/local/bin) it seems to work fine. Eg,

$ ln -s /usr/bin/python3 /some/other/path/python
$ export PATH=/some/other/path:$PATH
$ which python
/some/other/path/python
$ python
Python 3.8.9 (default, Jul 19 2021, 09:37:32)
[Clang 13.0.0 (clang-1300.0.27.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

However, this is not a tenable solution and I have hundreds of scripts that rely on #!/usr/bin/env python. Is there a way to get xcode-select to stop prompting me to install command line tools for python?

I'm getting the same repeated prompt while trying to set up playwright in VSCode.

npm ERR! 2 warnings generated. npm ERR! xcode-select: Failed to locate 'python', requesting installation of command line developer tools. npm ERR! make: *** [Release/sass.a] Error 72 npm ERR! *** ERR! build error npm ERR! *** ERR! stack Error: make failed with exit code: 2 npm ERR! *** ERR! stack at ChildProcess.onExit (/Users/!/repos/Sia-dashboard/node_modules/node-***/lib/build.

clicking install on modal begins download and installation but process isn't completed, as when returning to VSCode to continue playwright setup, I get the same error messages again

Python is installed (Python 3.10.5), I have previously installed Xcode command line developer tools, so I'm not sure why I'm stuck in this loop.

 
  • Create a symlink as vishal098 suggested below.

    1 year ago
Add a Comment

Doing the following command

xcode-select -p

results in

/Library/Developer/CommandLineTools

Then I took a look at /Library/Developer/CommandLineTools/usr/bin/ didn't have any python binary. However there was a python3 binary. So I created a symlink and this solved my problem. Following is the command I ran

sudo ln -s /Library/Developer/CommandLineTools/usr/bin/python3 /Library/Developer/CommandLineTools/usr/bin/python

This created the required python binary for xcode and solved the issue.

So general solution would be to find out where xcode-select is looking for python binary and then create a symlink in that location

 
  • Thanks macos 12.4; xcode 13.4.1; xcode-select -p results in /Applications/Xcode.app/Contents/Developer Good enough for now

    1 year ago
  •  
  • Thank you @vishal098! Your solution worked for me.

    1 year ago
  •  
  • Thanks ! Worked for me.

    1 year ago
 
 

same issue

 
  • Thanks! That really works for me.

    11 months ago
Add a Comment

I've spent four days on this already. Reinstalled my system tried all of the mentioned above suggestions and a bunch more from stack overflow and it's still not working properly.

I'm on macOS 12.5 and Xcode 13.4.1. I'm building an app using NativeScript and I can't release the app because every time I go to product > archive Xcode says Python command requires the command line tools. When I agree to install it will look like it installed but then start over.

Xcode-select -p results in /Applications/Xcode.app/Contents/Developer

I tried:

sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Applications/Xcode.app/Contents/Developer/usr/bin/python

and

sudo ln -s /Library/Developer/CommandLineTools/usr/bin/python3 /Library/Developer/CommandLineTools/usr/bin/python

None helped. I also tried

sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/python3.8 /Applications/Xcode.app/Contents/Developer/usr/bin/python

as I noticed there's python3.8 in Xcode's folder but that didn't work either. I'm a bit confused why Xcode is looking for Xcode in it's own folder now and doesn't use python3 that comes with macOS.

In addition to all of the above I also tried installing global version of Python using pyenvand followed the instructions listed on NativeScript docs https://docs.nativescript.org/environment-setup.html#macos-ios

Please help

 
  • These updated Nativescript docs helped me! I had the exact same issue as you on MacOS Ventura https://beta.docs.nativescript.org/setup/macos#installing-python-and-six

    1 year ago
Add a Comment

The solution for me was to uninstall python I previously installed using pyenvand just do it via homebrew with brew install python - it installs v3.9.13. And the final step is to run

sudo ln -s $(which python3) /usr/local/bin/python

How do I uninstall python?

i couldn't find the original post - thanks that person- manually install from that link solved my problem https://developer.apple.com/download/all/?q=command%20line%20tools

This fixed it for me xcodebuild -runFirstLaunch

 
  • Thanks, that was what did it for me! Just suddenly started today.

    1 year ago
  •  
  • Indeed. I was getting a big traceback and sh: line 1: 2700 Abort trap: 6 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null just running clang. But after xcodebuild -runFirstLaunch and it works now! Thanks!

    1 year ago
  •  
  • Thank you, did work for me too!

    1 year ago
 
 

Only this helps me. Thanks for sharing.

This is the only thing that worked for me as well thank you :)

xcodebuild -runFirstLaunch - did work for me, thank yuo!

Wow Apple, ***... get your shit together.

~> xcodebuild -runFirstLaunch
Install Started
1%.........20.........40.........60.........80........Install Succeeded

Worked For me!

 
  • xcodebuild -runFirstLaunch

    Works great - thanks!

    1 year ago
Add a Comment
  1. Page 1 of 2
  2. Last
 
 

posted on 2023-12-09 04:08  红色MINI  阅读(639)  评论(0编辑  收藏  举报

导航