How can I change the Framework path my Python file is referring?

I'm trying to run an 3rd party application with Python. I understand that Monterey has done away with the System installed Python 2.7, however this application was released before Monterey. When I try to run it, I get:

python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No such file or directory

The programming for the application is looking for the Framework file in /System/Library/Frameworks. However, since Monterey got rid of the system installed Python, Python.framework does not exist in System/Library/Framework. I had to download it on my own, and because of that the framework file only appears in Library/Frameworks.


How can I change the path that Terminal runs when trying to access Python framework through a pre-existing Python application?

Posted on Oct 12, 2022 02:34 PM

Reply

Similar questions

13 replies

Oct 12, 2022 05:57 PM in response to MrHoffman

Sorry, I don't think I understand... I updated the PATH= to the correct path where Python is actually located using nano .zsh and export PATH, but it is still referencing the old, incorrect path.


The incorrect path is:

/System/Library/Framework.....

and the correct path where Python lives is just:

/Library/Framework....

not in the System folder. I need Python to reference the Library folder straight from my HD, not System > Library.

Oct 12, 2022 05:30 PM in response to MrHoffman

Hm. I tried doing this, but it looks like it's still referencing the same path as before. In Terminal, I ran:

nano .zsh


Then I input the correct path, which is exactly the same as before except WITHOUT /System in front:

PATH="/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python/bin:${PATH}" 
export PATH


I try to run the Python application again. I still get the same "No such file or directory" message, and "/System" is still being included at the front of the path. I get:

python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No such file or directory


How did you remove "/System" from the referenced path?


MrHoffman wrote:

I ended up using a variation of this:

https://stackoverflow.com/questions/3696124/changing-python-path-on-mac


Oct 12, 2022 07:00 PM in response to catherine.deangelis

Usual spot for establishing PATH for zsh on macOS would be in .zprofile


The following is a pruned-down version of a local .zprofile login:


export PATH="$PWD:$HOME/bin:/usr/local/bin:${PATH}"
export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export MANPATH="/usr/share/man:/usr/local/share/man"
export EDITOR="/usr/bin/vim"


You’ll need to switch to and use the local Python 2 path in that.


Once you have .zprofile updated, close the terminal window and re-open it.


To then see the translation of PATH:


echo $PATH


Oct 13, 2022 04:09 AM in response to catherine.deangelis

That third-party posix_spawn module was last updated in 2015 via PyPy, and for some unknown reason, is attempting to directly access the Python binary within the Python bundle in that now outdated System Python 2.7 framework location. Odd it would do that when the same binary would have been located by Apple in /usr/bin/python at the time this code was developed.


You won't fix this outdated module hardcoding issue by reinstalling Python 2.7.18 from Python.org, or by changing any PATH statement in ~/.zshrc or ~/.zprofile files. The inclusion of the posix_spawn module breaks this third-party application you are attempting to use, and unless the vendor has replaced that posix_spawn module with newer code to workaround this issue. you are very likely done with this app on Monterey.

Oct 13, 2022 07:16 AM in response to VikingOSX

VikingOSX wrote:

That third-party posix_spawn module was last updated in 2015 via PyPy, and for some unknown reason, is attempting to directly access the Python binary within the Python bundle in that now outdated System Python 2.7 framework location. Odd it would do that when the same binary would have been located by Apple in /usr/bin/python at the time this code was developed.

You won't fix this outdated module hardcoding issue by reinstalling Python 2.7.18 from Python.org, or by changing any PATH statement in ~/.zshrc or ~/.zprofile files. The inclusion of the posix_spawn module breaks this third-party application you are attempting to use, and unless the vendor has replaced that posix_spawn module with newer code to workaround this issue. you are very likely done with this app on Monterey.


Two options exist there then: add a link at the location (easiest), or xxd hexdump the app or module performing the posix_spawn, find and alter the string, and xxd hexdump it back to working (not particularly difficult, probably requires re-signing or overriding signing).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can I change the Framework path my Python file is referring?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.