How to Install Pyenv on Your Mac?
- Hey there! Want to manage multiple Python versions on your Mac? Well, Lee John Huk from the New World has got you covered with a simple guide to installing Pyenv.
- First off, you’ll need to grab a script from the official Pyenv installation link.
- Once you’ve copied that command, just paste it into your terminal and execute it.
- After installing, don’t forget to add a script to your bash configuration file or shell.
- Restart your terminal, run
pyenv version
to make sure everything’s good to go, and you can list your Python versions withpyenv versions
. - If you need a specific Python version, just type
pyenv install
. - Finally, set your global Python version with
pyenv global
and double-check your installed versions usingpyenv versions
again!.
How do you set up Python versions easily?
- If you’re looking to use a specific Python version in a directory, it’s super easy! Just create your directory with
mkdir [directory_name]
, and then set your desired version, like 3.10.14, by runningpyenv local 3.10.14
. - When you check the Python version outside of this directory using
python --version
, you’ll see the global version. - But once you’re inside that directory, it will show the version you specified—great for project-specific needs! For AI projects that need different package installations, it’s a good idea to kick things off with a virtual environment to dodge those pesky package conflicts.
- You can create a virtual environment with pyenv by simply installing Virtualenv using the provided script, and don’t forget to tweak your Bash configuration to include that additional script!.
How to Set Up a Python Virtual Environment?
- In this segment, we’re diving into the setup for an advanced AI project using Python.
- First up, we create a virtual environment called ‘AI’ with version 3.11, which is pretty neat! To keep track of all your virtual environments, just run ‘pyenv versions’, and if you want to set the AI environment for your current folder, use ‘pyenv local AI’.
- Need to install some packages? No problem! Just grab them with pip.
- And if you ever want to get rid of that environment, simply use ‘pyenv uninstall’ and confirm your choice.
- Overall, this little guide walks you through installing pyenv to keep your Python versions and virtual environments organized..