0% found this document useful (0 votes)
35 views

Python Environment

The document outlines the steps to install homebrew, pyenv, Python, Poetry and set up a Python environment on MacOS for a data science project. It details downloading homebrew via an alternate method when the default curl command fails. It also addresses fixing a certificate error when installing Poetry and adding paths to enable using pyenv and Poetry commands from any directory. The last steps clone a forked GitHub repository, remove psycopg2 from dependencies and install packages in a virtual environment created with pyenv.

Uploaded by

Seshasai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Python Environment

The document outlines the steps to install homebrew, pyenv, Python, Poetry and set up a Python environment on MacOS for a data science project. It details downloading homebrew via an alternate method when the default curl command fails. It also addresses fixing a certificate error when installing Poetry and adding paths to enable using pyenv and Poetry commands from any directory. The last steps clone a forked GitHub repository, remove psycopg2 from dependencies and install packages in a virtual environment created with pyenv.

Uploaded by

Seshasai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

macOS Monterey

Version 12.3.1

Install home-brew:

Link : https://brew.sh

meghanaseshasai@Meghanas-MacBook-Air code % /bin/bash -c "$(curl


-fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/
install.sh)"
curl: (28) Failed to connect to raw.githubusercontent.com port 443
after 75246 ms: Operation timed out

Alternate home-brew installation:

git clone https://github.com/Homebrew/brew homebrew


eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"

Installing pyenv

Link : https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-virtualenv

brew install pyenv


brew install pyenv-virtualenv

Installing Python

pyenv install 3.10.6

Installed Python-3.10.6 to /Users/meghanaseshasai/.pyenv/versions/


3.10.6

Installing Poetry

Link : https://python-poetry.org/

curl -sSL https://install.python-poetry.org | /Users/


meghanaseshasai/.pyenv/versions/3.10.6/bin/python3 -

Certificate error:
Error:
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'
error.

Link: https://stackoverflow.com/questions/68275857/urllib-error-urlerror-
urlopen-error-ssl-certificate-verify-failed-certifica
Setting the PATH: (For both pyenv and poetry)

meghanaseshasai@Meghanas-MacBook-Air /etc % sudo vi paths

Add `export PATH="/Users/meghanaseshasai/.local/bin:$PATH"` to your


shell configuration file.

OR

Link: https://techpp.com/2021/09/08/set-path-variable-in-macos-
guide/#:~:text=In%20case%20you%20want%20to,or%20zsh%20(z%20shell)

nano ~/.zshrc

Add: export PATH=$PATH:/path/to/directory

source ~/.zshrc

Alternatively, you can call Poetry explicitly with `/Users/


meghanaseshasai/.local/bin/poetry`.

meghanaseshasai@Meghanas-MacBook-Air code % /Users/


meghanaseshasai/.local/bin/poetry --version
Poetry (version 1.5.1)

Creating pyenv environment

pyenv virtualenv 3.10.6 DataScience-3.10.6

Activating pyenv environment

pyenv activate DataScience-3.10.6

echo $PATH

/Users/meghanaseshasai/.pyenv/shims:/Users/meghanaseshasai/ps1/code/
homebrew/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/meghanaseshasai/
ps1/code/homebrew/bin:/Users/meghanaseshasai/ps1/code/homebrew/
sbin:/Users/meghanaseshasai/.local/bin:/usr/local/bin:/usr/bin:/
bin:/usr/sbin:/sbin

Cloning from forked repository

(DataScience-3.10.6) meghanaseshasai@Meghanas-MacBook-Air code % git


clone [email protected]:meghanaseshasai/dt-expert-bot.git

(DataScience-3.10.6) meghanaseshasai@Meghanas-MacBook-Air code % cd


dt-expert-bot
(Use: ‘nano pyproject.toml’ to remove the line containing psycopg2
in the file.)

(DataScience-3.10.6) meghanaseshasai@Meghanas-MacBook-Air dt-expert-


bot % poetry install

python3
import django
print(django.get_version())
4.2.1

git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv


root)/plugins/pyenv-virtualenv
cd .pyenv
cd plugins
cd pyenv-virtualenv
git pull

You might also like