K0nkere / MLOps_Car-prices-project

Covers the most important stages of ML system / Auction car prices prediction model for MLOps-zoomcamp
0 stars 0 forks source link

Conda virtual environment #11

Open K0nkere opened 2 years ago

K0nkere commented 2 years ago

Creation of conda virtual environment

conda create -n mlops-project-env python=3.9 list on venvs conda-env list running conda activate mlops-project-env

Create and go into folder 1-experiment-tracking requirements.txt

boto3
pyarrow
pickle-mixin
pandas
numpy
jupyter
scikit-learn==1.0.2
hyperopt
xgboost
mlflow
seaborn
pip install -r requirements.txt

List of installed packages

conda list -n mlops-project-env

To locate a kernel of conda venv its need to run under the venv which python > /homw/winx/.conda/envs/mlops-project-env/bin/python Sometime its need to do --force-reinstall of packages for specified venv

/homw/winx/.conda/envs/mlops-project-env/bin/python -m pip install --upgrade pip
/homw/winx/.conda/envs/mlops-project-env/bin/python -m pip install -r requirements.txt --force-reinstall

Its need to add it to the kernels list of VSCode > Ctrl+Shift+P >enter enterpreter path and again Ctrl+Shift+P > Select Interpreter > from conda list mlops-project-env After that I can choose it from kernels list of VSCode

Or under Jupyter Notebook from browser via run in terminal jupyter notebook under conda env and tunneling Installing ipykernel conda install -c anaconda ipykernel Adding the new kernel to Jupyter Notebook kernels list python -m ipykernel install --user --name=mlops-project-env Now it is possible to select corresponding kernel from Kernel>Change Kernel menu so the previously installed libraries can be imported

Adding env variables inside Jupyter Notebook in order to use os.getenv() %env PUBLIC_SERVER_IP=51.250.101.205 or

Install python-dotenv 
pip install python-dotenv
Load the .env file in a Jupyter notebook
%load_ext dotenv
%dotenv

If it is need to install Jupyter Notebook under the env sudo apt install jupyter or under the conda env conda install -n mlops-project-monitoring ipykernel --update-deps --force-reinstall