• Collection

    • General
  • System

    • Old System
  • AI

    • Python Env Setting
    • 认证
    • Ollama
    • WebUI Setting
  • Raspberry

    • Raspberry Hardware Info
    • Raspberry Setting
  • Daily

    • Daily Tools
  • Resource

    • 逆向
    • Book
    • BlockChain
  • Environment

    • Linux
    • Can Debug
    • Can Detail Debug

pyenv

brew update
brew install pyenv
brew install pyenv-virtualenv

Add pyenv to your shell startup file:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
source ~/.zshrc

check installed correctly:

pyenv --version

List available Python versions:

pyenv install --list

# specific version
pyenv install 3.9.10

Set a global Python version:

pyenv global 3.11.4

Set a local Python version in a project directory:

cd my_project
pyenv local 3.9.10

Create a Virtual Environment for Jupyter

pyenv virtualenv 3.9.10 jupyter-env

List available virtual environments:

pyenv virtualenvs

Activate the Environment

pyenv activate jupyter-env

Check if the correct Python version is active:

python --version

Install Jupyter Notebook

pip install jupyter

jupyter --version

Add Virtual Environment to Jupyter as a Kernel

pip install ipykernel

python -m ipykernel install --user --name=jupyter-env --display-name "Python (jupyter-env)"

jupyter kernelspec list

TaskCommand
Install pyenvbrew install pyenv pyenv-virtualenv
Install Python 3.9.10pyenv install 3.9.10
Create a virtual environmentpyenv virtualenv 3.9.10 jupyter-env
Activate the virtual environmentpyenv activate jupyter-env
Install Jupyter Notebookpip install jupyter
Add virtual environment to Jupyterpython -m ipykernel install --user --name=jupyter-env --display-name "Python (jupyter-env)"
Start Jupyter Notebookjupyter notebook
List available Jupyter kernelsjupyter kernelspec list
Deactivate the virtual environmentpyenv deactivate
Delete the virtual environmentpyenv virtualenv-delete jupyter-env
Last Updated:
Next
认证