Pyenv install -list # Installing different Python versions Installing multiple versions of Python and switching between them is quite simple using Pyenv: # Checking for available python versions Great! Now that we have Pyenv installed on our computer we can go ahead and install any python version without messing things up. Typing type -a python should give an output like this: python is /Users/atzmonky/.pyenv/shims/python With the ~/.pyenv/shims directory out front. If all went well it should return something like: /Users/atzmonky/.pyenv/shims:/Users/atzmonky/.pyenv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin To check our installation we can type echo $PATH in a new terminal window. # Or just Close the terminal and start a new one Checking our initial set up usr/bin/ruby -e "$(curl -fsSL )" # And install Pyenv with Homebrew:īrew install pyenv # Add pyenv to the shell startup script (~/.zprofile for zsh or ~/.bash_profile for bash):Įcho 'export PYENV_ROOT="$HOME/.pyenv"' > ~/.zprofileĮcho 'export PATH="$PYENV_ROOT/bin:$PATH"' > ~/.zprofileĮcho -e 'if command -v pyenv 1>/dev/null 2>&1 then\n eval "$(pyenv init -)"\nfi' > ~/.zprofile # Reload profile: # Install Homebrew and Xcode tools dependencies We will first install Homebrew and some dependencies and then use it to download and install the rest. We will use Homebrew, a common and widely used package manager, to install Pyenv and Pipenv. Instead of manually manage applications, I prefer using a package manager to install, update, and remove unneeded software. Since mac OS doesn’t come with a default package manager out of the box, there are several ways to setup and install Python. If you are not familiar with Terminal at all, you can follow a gentle introduction to comfortably tuck you in. CLI might look as if it is very old fashioned, nevertheless, it offers many advantages and is considered by many to be the ultimate seat of power. The Command Line is a powerful and versatile tool for interacting with the computer. We will use the Terminal mainly because it’s the only (but very easy and strait-forward) way to install and activate the mentioned tools. While the latter manages our python versions in an orderly fashion, Pipenv not only fetches and installs Python packages but also creates and handles a virtual environment to capsulate all packages and dependencies for a project.Īll installations and actions will be done using the MacOS Command Line Interface (CLI) which is called Terminal. The second tool we are going to use is Pipenv, a complementary for Pyenv. This way, no conflicts occur and even if we mess up something with Pyenv, our system python stays intact and nothing breaks within the OS. Every new Python version that I install ends up in a separate folder, and Pyenv modifies the $PATH variable telling the computer to use specific Python versions (and not the system Python). The best thing with Pyenv is that it doesn’t interfere with the original Python version installed on my machine. On top of that, it is very easy to assign and use different virtual python environments or integrate it as a python interpreter for P圜harm, a popular python IDE which I currently use. Pyenv is a Simple Python version management tool, which lets us install, manage and switch between multiple versions of Python. Let’s say we want to create a project environment in Python 3.7 and another in Python 3.9? Enter Pyenv and Pipenvįortunately, A handy tool called Pyenv might just make our life a bit easier. Basically, we would like to have the option to install several versions of python, dependencies and packages without any conflicts. In order to take advantage of the latest versions of Python, we would need to install a newer version alongside the system one. However, it’s well out of date from what Python recommends using for development or data analysis. Wether we like it or not, Python 2.7 comes pre-installed on Mac OS and it shouldn’t be messed with, as it’s used by the system itself (Several parts of the OS rely on python 2 scripts that Apple haven’t updated yet). This is the setting I ended up with, hopefully it will help you. Alarming posts about a good way and a bad way of installing python, and all sort of remedies to prevent future catastrophe when wildly installing packages for several versions of python without any sensible order. Googling around and looking for a simple guide to set-up a Python development environment can be sometimes quite puzzling and even intimidating. Setting up a Python environment on a mac for the average user can turn out to be quite baffling.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |