When you're in a development environment, you often suffer from differences in installed libraries. Furthermore, since Python 2.x series and Python 3.x series may be in parallel, virtualenv should be used to manage the environment.
Python
Create a batch file that registers environment variables for running python. To run python, double-click this batch file to launch a command prompt.
python27.bat
@echo off
:::Preparation before execution
set EXEC_DIR=%~dp0
::: python
PATH=C:\usr\local\bin\Python27;C:\usr\local\bin\Python27\Scripts;%PATH%
cd %EXEC_DIR%
PROMPT #$S
%ComSpec%
# python get-pip.py
Get-pip.py is not needed after execution, so delete it
# pip install virtualenv
Usage: python -m virtualenv ${Folder where you want to create a virtual environment}
Create a virtual environment called "hoge" and start / end
Creating a virtual environment (Python 2.7)
# python -m virtualenv --python=C:\usr\local\bin\Python27\python.exe hoge
Already using interpreter C:\usr\local\bin\Python27\python.exe
New python executable in hoge\Scripts\python.exe
Installing setuptools, pip...done.
#
Start virtual environment
# hoge\Scripts\activate
(hoge) #
End of virtual environment
(hoge) # hoge\Scripts\deactivate
#
Recommended Posts