7

After installing Homebrew using the script on their homepage and checking if everything was alright with brew doctor, I issued brew install python3 in order to install Python 3 on my Mac.

Everything seemed fine until I tried running python3 --version; I ended up getting:

-bash: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3: No such file or directory

I checked in the file directory to see what was going on and indeed, I didn't see any files pertaining to Python in my framework folder. It also looks like Python 2.7 isn't on my Mac either.

This is what I got after installing Python 3:

Summary /usr/local/Cellar/python3/3.5.1: 3,438 files, 51.5M

edit_2: maybe this has something to do that there is no Python framework? I just read this off the Python website:

The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
vcyf56rtrfc
  • 373
  • 3
  • 4
  • 9
  • 1
    My own personal experience with Python through brew made me come to this conclusion: Screw brew (for Python...I still use it for other things), go to the [main Python site](https://www.python.org/downloads/) and just download it from there. I know it might sound annoying to suggest this to you, but I just didn't want to bother with what different things brew was doing, and the main site just had everything working the way I'd expect it out-of-the-box. – idjaw Mar 15 '16 at 03:07
  • 1
    @idjaw No worries; I would actually be irritated with the book for even making me download stuff I didn't really need to. I'll wait a bit to see if anybody has a way to fix this issue. Otherwise, I'll try figuring out how to uninstall everything I installed through Homebrew and follow your advice. – vcyf56rtrfc Mar 15 '16 at 03:11
  • My homebrew installs Python (2 and 3) in `/usr/local/`; how come your homebrew installs in `/Library/Frameworks`? –  Mar 15 '16 at 03:13
  • @Evert I have no clue; I'm new to programming. – vcyf56rtrfc Mar 15 '16 at 03:14
  • See if there's something in `/usr/local/bin/` instead. –  Mar 15 '16 at 03:14
  • @Logarhythms did you see [this](http://docs.python-guide.org/en/latest/starting/install/osx/) or [this](https://hackercodex.com/guide/python-development-environment-on-mac-osx/)? – idjaw Mar 15 '16 at 03:15
  • @Evert I checked and the only intelligibly named thing I found were brew and charm files. – vcyf56rtrfc Mar 15 '16 at 03:19
  • No warnings after `brew install python3` or after running `brew doctor` again? It feels that there was already a Python 3 executable installed on your system (in a different way), and homebrew doesn't (yet) want to fully symlink its own executables, to not mess around with the existing python3 command. –  Mar 15 '16 at 03:22
  • @idjaw Most of that went over my head, but from what I gathered, I already used `brew install python3` successfully (with the Xcode alteration) per the second link. I'm hesitant (& ignorant) of changing the PATH because if that doesn't work, then that only adds to my troubles of changing/uninstalling all of this crap. Other than that, I already did what the first link suggested. – vcyf56rtrfc Mar 15 '16 at 03:25
  • @Evert no warnings after issuing both commands - just a "Your system is ready to brew." message. – vcyf56rtrfc Mar 15 '16 at 03:26
  • Your edit shows that there is indeed a homebrewed Python 3.5. The other Python that gives you the error, must be some result from a previous attempted install (guessing there). Usually, homebrew creates a symbolic link `/usr/local/bin/python3.5 -> /usr/local/Cellar/python3/3.5`; I'm not sure why this time, but see a previous comment of mine. –  Mar 15 '16 at 03:46

4 Answers4

11

I think I detected what the problem is.

I guess that, at a certain moment, you had installed python from the official site instead of via Homebrew. In my case, I installed it via the official website Python 3.6.4. A few months later, I wanted to upgrade it and noticed that it was very complex. So, I decided to move to Homebrew. Open a terminal window and let's try to fix this:

  1. First, let's uninstall previous Python versions:

     sudo rm -rf /Library/Frameworks/Python.framework
     sudo rm -rf /usr/local/bin/python3
    
  2. Then, remove the previous frameworks from the $PATHvariable:

     nano ~/.bash_profile
    

You will see something like that:

    # Setting PATH for Python 2.7
    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
    export PATH

    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
    export PATH`

This is the problem: These paths don't exist. Comment the $PATH editions (or erase them):

    # Setting PATH for Python 2.7
    # The original version is saved in .bash_profile.pysave
    # PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
    # export PATH

    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    # PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
    # export PATH
  1. Restart the computer and install via Homebrew Python 2 and 3:

     brew update
     brew install python
     brew install python3
    

This worked for me. Now, if type python3 --version I get Python 3.7.0, and everything works fine :)

Román Cárdenas
  • 492
  • 5
  • 15
5

I had the same issue. I learned how to fix it for good:

  1. Open "Applications" in Mac Finder and drag Python to the trash bin.
  2. Empty the trash bin

If you have an error as above, then an official Python installation has been performed (as others have mentioned) via e.g. Python.org. This creates some kind of alias for the python or python3 commands outside a Bash alias. So while the command where python3 may point to /usr/local/bin/python3, python3 will still try to call /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.

Note:

  • the MacOS system Python is /usr/bin/python
  • Homebrew Python(s) will be located in /usr/local/bin/
  • Pythons installed as an Apple application live in /Library/Frameworks/Python.framework/
Cory
  • 748
  • 7
  • 18
2

Okay, this is what I gathered:

vcyf56rtrfc
  • 373
  • 3
  • 4
  • 9
  • This is yet another way of installing python in general, while OP was explicitly addressing problems with Homebrew. – gustafbstrom Jan 28 '17 at 09:39
1

This error:

-bash: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3: No such file or directory

suggests a remnant of some previous (attempt at an) installation of Python 3 using a different way (not Homebrew).

(I think this is actually where the Python installation from www.python.org goes. I wouldn't know though, as I've either never tried that package, but only installed the www.python.org version from source. This would suggest, though, that you already had an attempt at installing Python 3.5, something failed, and you're now trying Homebrew instead.)

I'd suggest moving (renaming) this out of the way, so your system doesn't pick it up. Something like

mv /Library/Frameworks/Python.framework/Versions/3.5 /Library/Frameworks/Python.framework/Versions/3.5-aside

(if there other versions of Python 3 in that directory, you may want to do the same for those.)

Also check that python3 isn't an alias. Commands such as

which python3
type python3
alias python3

will reveal that.

With the interfering Python 3 out of the way, try re-installing Python 3 through homebrew again. You may have to do an uninstall + reinstall.
Read carefully any homebrew messages once the installation is done, in particular if it mentions something about linking files: you may need to run something like brew link python3.