[PYTHON] Try using virtualenv (virtualenvwrapper)

Try using virtualenv (virtualenvwrapper)

If you use pyenv, you can select the Python version for each directory and it will not pollute the environment, but pip is installed globally and you can not manage it for each project.

In such a case, by using virtualenv, you can prepare a Python virtual environment and manage Python versions and modules in it. And the virtualenv wrapper is a more convenient extension of that virturalenv. It seems.

Install virtualenvwrapper

If you are using Mac OS X and homebrew or pyenv

Can be installed with brew

$ brew install pyenv-virtualenvwrapper

Describe the following in ~ / .bashrc and ~ / .zshrc

$ vim ~/.zshrc
export PYENV_VIRTUALENVWRAPPER_PREFER_PYVENV="true"
pyenv virtualenvwrapper

$ source ~/.zshrc

Reference: https://github.com/yyuu/pyenv-virtualenvwrapper

Try to create a virtual environment with virtualenv

$ mkvirtualenv testenv
(testenv) $ 

You can create a virtual environment with mkvirtualenv ENVNAME. ENVNAME is the name of the virtual environment. If you are in a virtual environment, (testenv) $ and the virtual environment name will be displayed at the prompt.

Try to see if the environment is really different.

(testenv)$ pip list
pip (1.5.6)
setuptools (3.6)

pip list displays a list of packages installed with pip. Exit the virtual environment and try to display pip list in the normal environment. Use the deactivate command to exit the virtual environment.

(testenv)$ deactivate
$ pip list
argparse (1.2.1)
pip (1.5.6)
setuptools (5.4.1)
stevedore (0.15)
virtualenv (1.11.6)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.3.1)

It can be seen that the normal environment and the virtual environment are firmly separated. If you want to enter the created virtual environment, enter it with the following command.

$ workon testenv
(testenv)$

For other usage of virtualenvwrapper, refer to Documentation.

Recommended Posts

Try using virtualenv (virtualenvwrapper)
Try using virtualenv now
Try using docker-py
Try using cookiecutter
Try using PDFMiner
Try using geopandas
Try using Selenium
Try using scipy
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
[Azure] Try using Azure Functions
Try using W & B
Try using Django templates.html
[Kaggle] Try using LGBM
Try using Python's feedparser.
Try using Python's Tkinter
Try using Tweepy [Python2.7]
Try using Pytorch's collate_fn
Try using PythonTex with Texpad.
[Python] Try using Tkinter's canvas
Try using Jupyter's Docker image
Try using scikit-learn (1) --K-means clustering
Try function optimization using Hyperopt
Try using matplotlib with PyCharm
Try using Azure Logic Apps
Try using Kubernetes Client -Python-
[Kaggle] Try using xg boost
Try using the Twitter API
Try using OpenCV on Windows
Try using Jupyter Notebook dynamically
Try using AWS SageMaker Studio
Try tweeting automatically using Selenium.
Try using SQLAlchemy + MySQL (Part 1)
Try using the Twitter API
Try using SQLAlchemy + MySQL (Part 2)
Try using Django's template feature
Try using the PeeringDB 2.0 API
Try using Pelican's draft feature
Try using pytest-Overview and Samples-
Try using folium with anaconda
Try using Janus gateway's Admin API
[Statistics] [R] Try using quantile regression.
Try using Spyder included in Anaconda
Try using design patterns (exporter edition)
Try using Pillow on iPython (Part 1)
Try using Pillow on iPython (Part 2)
Try using virtualenv, which can build a virtual environment for Python
Try using Pleasant's API (python / FastAPI)
Try using LevelDB in Python (plyvel)
Try using pynag to configure Nagios
Try using PyCharm's remote debugging feature
Try using ArUco on Raspberry Pi
Try using cheap LiDAR (Camsense X1)
[Sakura rental server] Try using flask.
Try using Pillow on iPython (Part 3)
Reinforcement learning 8 Try using Chainer UI
Try to get statistics using e-Stat
Try using Python argparse's action API