No video

Installing and Managing Multiple Versions of Python - macOS Mojave, Catalina, Big Sur

  Рет қаралды 12,751

The Data Science Mentor

The Data Science Mentor

Күн бұрын

In this video, I demonstrate how to install, manage, and easily switch between multiple versions of Python 3 with Homebrew using pyenv on macOS Mojave or older, Catalina, or Big Sur.
My demonstration consists of installing 3 versions of Python 3 as well as the last release of Python 2 which is version 2.7.18.
Please note that, as I mention in the video, it is not really recommended to install older versions of Python 3, but in rare circumstances where you need to use a Python package or library and it is not compatible with the latest release, then you can use pyenv to install and manage multiple versions of Python.
You can find pyenv’s documentation on Github here: github.com/pye...
In order to be able to use pyenv, you need to have Homebrew installed. If you don’t, I show exactly how to do that in the following videos:
For macOS Catalina or Big Sur: • How to Install and Pro... (Follow up to minute 8 and 11 seconds)
For macOS Mojave or Older: • How to Install and Pro... (Follow up to minute 9 and 30 seconds)
#datasciencementor #datascience #datascience_tools #python #python3 #python2 #pyenv #multiple_versions_python #macOS

Пікірлер: 77
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
I received many comments on my videos on how to install and manage older versions of Python 3. In this video, I show one way of doing that. I hope you find the video helpful. If you have any questions or comments, please feel free to share them here, and I will be more than happy to help out.
@josephgarza5973
@josephgarza5973 3 жыл бұрын
Professor, I believe this code needs to be entered in a .zshrc file since this is the ending of the code itself. NOTE CODE (( echo -e 'if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)" fi' >> ~/.zshrc )) I am absolutely new to this but I did learn from you previous video that vim will make the dot zshrc folder if it is not in the root folder yet. So, I do not have it yet and that means that when I finally enter vim dot zshrc my terminal will be prompted to make the folder then, should I just stick the code in that file switching the the INSERT MODE by pressing I and pasting then just escaping and entering colon wq. and rebooting? Should this enable the shims and autocompletion, professor?
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@Gwyn Parkman Yes, I thought I would speed up the parts where I install the different versions in order not to bore you with long periods of silence =)
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@@josephgarza5973 According to the documentation here: github.com/pyenv/pyenv, you only need to do that as part of a series of steps if you plan to fork the Github repository and contribute to it by making pull requests otherwise you don't need to. As for the .zshrc file, it is actually a file, not a folder. Yes, if the file does not exist in your home directory (the root directory is actually different), then when you run vim .zshrc, it will create the file for you. You got the rest correct. As for rebooting, you don't need to restart your computer, you simply quit Terminal by right-clicking the Terminal icon on Dock and selecting Quit from the pop-up menu. I hope this helps. If you have any other questions, don't hesitate to ask.
@josephgarza5973
@josephgarza5973 3 жыл бұрын
@@TheDataScienceMentor Well, professor. You're absolutely right and I did manage to install pyenv install 3.9.1 and I see both versions installed. Unfortunately, when I try to run pyenv install 2.7.7 I get the following error message. Top part says: Inspect or clean up the working tree at /var/folders/hx/cc---followed by numbers--- The bottom part has a message that reads like so: -- configure:error: Unexpected output of arch on OSX -- make: *** No targets specified and no makefile found. Stop. Any idea on what this might be due to or where this might lead to? Please?
@josephgarza5973
@josephgarza5973 3 жыл бұрын
@@TheDataScienceMentor I did some research and I found a blog that Python installation can not find zlib ( I believe that is a folder that patches or something) ... so I entered the code, like so: CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install but still got the same exact error message that I texted earlier so it could not have been, I do not believe it could be due to the same error: The error message still reads like so: --- configure: error: Unexpected output of arch on OSX. -- make: **** No targets specified and no makefile found. Stop. This error message still persists. The solution I found did nothing. Any ideas as to why and how to resolve this configure error, please?
@LukeHildreth
@LukeHildreth 3 жыл бұрын
Thanks for making this! Very helpful and easy to follow 🎉
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
No problem! I am really glad to hear that.
@rishikumar4205
@rishikumar4205 3 жыл бұрын
Yes Sir I also need it , thank u sir for your time and hard work and love for us .
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Thanks 079 RISHI!
@tariqr5808
@tariqr5808 3 жыл бұрын
Hi @The Data Science Mentor, I tried following your steps to install Python 3.6.13 and received the following: IThank you.
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Hi Tariq, what did you get? Was it an error?
@tariqr5808
@tariqr5808 3 жыл бұрын
@@TheDataScienceMentor Oh wow, thank you for your prompt reply. Sincere apologies, the message did not come up right. The error I received when I installed an older version was "Build Failed (OS X 11.4 using python-build 20180424)
@sofiaRamseena
@sofiaRamseena 3 жыл бұрын
@@tariqr5808 I got the same error any solution??
@MrMateopascual
@MrMateopascual 2 жыл бұрын
Same error here. Could you make a video solving this? Everything I find online is not related to OS X 11.6 (my version). Thanks :)
@justcruisin109
@justcruisin109 2 жыл бұрын
Great video - thanks.
@mohammadsamishaikh5247
@mohammadsamishaikh5247 3 жыл бұрын
Thank you… It made so easy to switch between python versions. Really helpful… 🙂🙂🙂
@JustinInBlack
@JustinInBlack 3 жыл бұрын
After hours of reading ton of google search's result and Stack Overflow answer just for "pygame is not defined". I pause learning python. Instead learning how to manage the version of python, installing package the right way and also control the version of Pip. And finally I'm here after hours! Really excited to run my python code confidently. I just have a quick question: When we use pyenv global to set python version as default, will it affects on all the projects that I'm doing? For example, I'm using Visual Studio Code. And I select python interpreter for every project that I use. So how's it compared to setting particular python version as default and using pyenv or venv ( create a virtual environment file)? Do you have a video that explain more about setting python? I think I would understand more when try it. Thank you for your works, sir. Liked and subcribed!
@lucaswehmuth
@lucaswehmuth 3 жыл бұрын
Brilliant tutorial!
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Thanks Lucas!
@sofiepatoor
@sofiepatoor 3 жыл бұрын
Thank you, this really helped me out!
@jaideepadhvaryu9642
@jaideepadhvaryu9642 3 жыл бұрын
I already have Python3.9 installed on my machine. I want to use pyenv to manage multiple versions esp because of tensorflow incompatibility. Do i need to uninstall 3.9 and then install 3.8 and 3.9 using pyenv. Or is there a way to pyenv existing python version Also, please create a video for clean and complete uninstall of one or more versions of python. You are doing job. Thank you.
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Hi Jaideep, I replied to your comment on my other video. I don't think you need to use pyenv, and having two versions of Python installed on your machine shouldn't cause any conflicts, because ultimately, it is what version you set to be the default, and it all has to do with how you set up your path. Anyway, let's continue the discussion in the comments section of the other video.
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Sorry Jaideep. I misread your comment and missed the part where you say you need to install an older version of Python to use TensorFlow. In this case, I think pyenv is a good way to manage multiple versions of Python. Try following this video, and let me know if you run into any problem.
@jaideepadhvaryu9642
@jaideepadhvaryu9642 3 жыл бұрын
@@TheDataScienceMentor So, i will need to brew uninstall 3.9, do the pyenv steps to install 3.8.5 and 3.9.2? Also, will i have to keep changing the python interpreter each time i change pyenv global
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@@jaideepadhvaryu9642 Yes. You don't really change the interpreter per se. When you run python not followed by anything else, it automatically invokes the interpreter in the version that is the default. So if Python 3.8.2 is the default, then when you run python, it invokes the Python 3.8.2 interpreter and so on. Make sense?
@jaideepadhvaryu9642
@jaideepadhvaryu9642 3 жыл бұрын
@@TheDataScienceMentor thank you so much 👍🏽
@ryanhandley382
@ryanhandley382 Жыл бұрын
Tensorflow is exactly why im here lmfao
@JustinInBlack
@JustinInBlack 3 жыл бұрын
tahnk sir
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
You are welcome, Ngoc!
@alsadler4013
@alsadler4013 Жыл бұрын
This is a great video for us MacOS users, wish I would have found this when I first started getting into coding. So, I already have both python 3.10 and 3.11 installed on my macbook, but I guess when I did it I followed a pc video and went to the python website and downloaded each tar.xz file. Either way, when I input pyenv versions comd, I get "* system (set by /Users/alsadler/.pyenv/version)" so I tried the python --version and got "zsh: command not found: python". So I then tried python3 --version and got "Python 3.10.11" I'm not sure why it's not showing the 3.11.3 version? I know I'm a little behind the 8 ball as this video is 2 years ago, but I hope you can help me out?
@JustinInBlack
@JustinInBlack 3 жыл бұрын
Ngoc Nguyen 1 second ago when I insert the command export PATH = "$(pyenv root") / shims: $PATH", I insert export PATH = "$(pyenv root" / shims: $PATH", so I basically miss the ")" in the "$(pyenv root" " , How can I combat to it and add ")" ? Thank you
@jatinvamja396
@jatinvamja396 3 жыл бұрын
when I try pyenv install 3.6.9 got an error configure: error: Unexpected output of 'arch' on OSX make: *** No targets specified and no makefile found. Stop. I am using mac OS Big sur 11.2.3 M1 chip ARM python 3.8.2 and 2.7.12 are already installed Can you help me please
@yanis417
@yanis417 3 жыл бұрын
I am going through the steps but I can only install 3.9 and 3.8 but not 3.7 or any version below. When I check the shims, there is no version below 3.8 there. Any new restrictions by Pyenv? Thanks
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Hi Yanis, why aren't you able to install 3.7? Are you getting an error message?
@yanis417
@yanis417 3 жыл бұрын
@@TheDataScienceMentor hi and thanks for the feedback yes i get this error : BUILD FAILED (OS X 11.2.2 using python-build 20180424) Inspect or clean up the working tree at /var/folders/lq/kql9dcw919v8bf0rz7ccs69c0000gn/T/python-build.20210308095056.6287 Results logged to /var/folders/lq/kql9dcw919v8bf0rz7ccs69c0000gn/T/python-build.20210308095056.6287.log Last 10 log lines: clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/deehive/.pyenv/versions/3.7.7/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/deehive/.pyenv/versions/3.7.7/include -DPy_BUILD_CORE_BUILTIN -c ./Modules/pwdmodule.c -o Modules/pwdmodule.o clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/deehive/.pyenv/versions/3.7.7/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/deehive/.pyenv/versions/3.7.7/include -DPy_BUILD_CORE_BUILTIN -c ./Modules/_sre.c -o Modules/_sre.o ./Modules/posixmodule.c:8436:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = sendfile(in, out, offset, &sbytes, &sf, flags); ^ clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/deehive/.pyenv/versions/3.7.7/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/deehive/.pyenv/versions/3.7.7/include -DPy_BUILD_CORE_BUILTIN -c ./Modules/_codecsmodule.c -o Modules/_codecsmodule.o 1 error generated. make: *** [Modules/posixmodule.o] Error 1 make: *** Waiting for unfinished jobs.... 1 warning generated.
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@@yanis417 I am sorry to hear that. This is what's challenging with installing older versions of Python. Some package somewhere on your machine that is necessary for the installation might not be compatible with that older version of Python. When did you install Homebrew? Try running brew upgrade before installing 3.7. Does it work now?
@yanis417
@yanis417 3 жыл бұрын
@@TheDataScienceMentor it is a new IOS installation, i reset my machine MacBook Pro 16. So homebrew is uptodate and I followed all the steps When I check the shims I can only find 3.8 and 3.9 Pyenv new restrictions ?
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@@yanis417 It is not really. Nothing is showing on their main page or in their documentation about any new restrictions. Let's try one thing at a time. I am assuming you are using Big Sur, am I right?
@ronn_zw
@ronn_zw 9 ай бұрын
This was helpful however. I had problems with installing python 3.10.10. I ended up using this command: arch -x86_64 pyenv install 3.10.10
@sarimkhan2306
@sarimkhan2306 2 жыл бұрын
I had python 3 already installed but still wrote the path ? and it is not working can any one guide me after 8:40
@user-or7ji5hv8y
@user-or7ji5hv8y 3 жыл бұрын
do we need to worry about the config conflicts from brew doctor?
@JustinInBlack
@JustinInBlack 3 жыл бұрын
I'm using MacOS Catalina and in my terminal is "%" sign istead of "$" sign. So I just simply replace "$" by "%" in every code that you used in the video? For example: export PATH = "%(pyenv root" / shims: % PATH" for export PATH = "$(pyenv root" / shims: $PATH"? Thank you
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Hi Ngoc, no no. I actually customized my Terminal and used a $ sign instead of the %. The $ simply marks the beginning of the line in my Terminal. So, don't change the % mark to the $ sign. I actually received more than one comment about the $ sign in my Terminal, so perhaps I can make a quick video on how to customize your Terminal.
@JustinInBlack
@JustinInBlack 3 жыл бұрын
@@TheDataScienceMentor oh thank you!
@josephgarza5973
@josephgarza5973 3 жыл бұрын
Excuse me, I have a question I hope you can help me out with. And, please note that I am absolutely new to programming and developing. In exactly TC: 4:13 in this video, you enter ^D. --- Can you tell me if this command is supposed to close the transaction that had been initiated when you entered "Python"? -- I can see that the next thing that happens is that it takes you straight to dsmentor: ~ and then you begin typing commands again.
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
Hi Teacher Joseph Garza, yes that is correct. You press Cntrl-d to exit the Python interpreter.
@josephgarza5973
@josephgarza5973 3 жыл бұрын
@@TheDataScienceMentor Ok, so it’s Cntrl D not carrot D. Well, I’m new to MacBook and programming at any rate. I’m working on a M1 MacBook Pro and I’m working on installing pyenv so that I can ultimately install Python 2.7.7 It’s been a real challenge and I’m going on my third day. I appreciate your reply.
@josephgarza5973
@josephgarza5973 3 жыл бұрын
@@TheDataScienceMentor If I run into any other issues would be ok if I drop a line, please?
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@@josephgarza5973 Do you really need to work with Python 2? At this point, you shouldn't be working with Python 2 at all, and I discuss why in this video: kzbin.info/www/bejne/ZqPKZ6GvltOLa7s. Only install pyenv if you REALLY REALLY need to work with multiple versions of Python. But if you are new to programming and developing, then there is no need for you to work with multiple versions of Python. Just go with the latest version and you should be more than fine. The above referenced video walks through the process of installing only the latest version of Python 3.
@TheDataScienceMentor
@TheDataScienceMentor 3 жыл бұрын
@@josephgarza5973 Sure! But as I said in my previous reply, if you are new to programming and developing, then no need to work with pyenv. Just install the latest version of Python 3.
@JustinInBlack
@JustinInBlack 3 жыл бұрын
when I run Vim .zshrc , it show ".zshrc" 1L, 53C, instead of "New File". Why is that? Thank you
@JustinInBlack
@JustinInBlack 3 жыл бұрын
When I open my terminal, it said " Last login: Fri Apr 2 01:56:49 on ttys000 /Users/justin/.zshrc:1: no such file or directory: /home/linuxbrew/.linuxbrew/bin/brew justin@Justins-iMac ~ % "
@JustinInBlack
@JustinInBlack 3 жыл бұрын
after hours of figuring it out myself, now I'm messed up and when I open my terminal, it's no longer ttys000 but ttys001 and " .zshrc:2: unmatched ". Please help me
@JohnMartin-jx1wz
@JohnMartin-jx1wz 2 жыл бұрын
Well that sure as hell screwed up my python even worse than anaaconda. Think i'll stick to sagemath that actually works. Python is a bag of hurt.
@amiaynarayan619
@amiaynarayan619 2 жыл бұрын
does not work for Big Sur.BUILD FAILED
@TheDataScienceMentor
@TheDataScienceMentor 2 жыл бұрын
It sure does.
Getting Started With pyenv to Manage Multiple Python Versions
14:13
КАКУЮ ДВЕРЬ ВЫБРАТЬ? 😂 #Shorts
00:45
НУБАСТЕР
Рет қаралды 3,1 МЛН
WHO CAN RUN FASTER?
00:23
Zhong
Рет қаралды 42 МЛН
Get 10 Mega Boxes OR 60 Starr Drops!!
01:39
Brawl Stars
Рет қаралды 16 МЛН
How to Install and Properly Set Up Python 3 - macOS Catalina or Big Sur
13:19
The Data Science Mentor
Рет қаралды 80 М.
Python install with pyenv on Mac
8:14
THETA 360 Developers
Рет қаралды 6 М.
What Happened To Google Search?
14:05
Enrico Tartarotti
Рет қаралды 3,1 МЛН
7 Python Code Smells to AVOID at All Costs
22:10
ArjanCodes
Рет қаралды 370 М.
The Fastest Way to Loop in Python - An Unfortunate Truth
8:06
mCoding
Рет қаралды 1,4 МЛН
Why UK 🇬🇧 is going Bankrupt? : Detailed Economic Case Study
20:37
Think School
Рет қаралды 1,4 МЛН
How Google's Chromium Took Over the Browser World
9:59
Eric Murphy
Рет қаралды 283 М.
Manage Multiple Python Versions with PyEnv
9:54
NeuralNine
Рет қаралды 19 М.
Getting Started on Ollama
11:26
Matt Williams
Рет қаралды 48 М.