When developing with Python, there are cases where you need to install libraries as you switch between virtual environments.
In my case, I sometimes need to manage packages using both pip and conda.
When changing virtual environments, you can save the package list from the previous environment (or the environment you want to replicate) as a text file and then load it into the new virtual environment for installation.
*Sometimes, when cloning code from GitHub, there might be a "requirements.txt" file containing the list of packages that need to be installed.
1. Using pip
When using pip, you can save the package list from the previous virtual environment as follows [1) Export], and then load the package list into the new virtual environment as follows [2) Import].
1.1) Save pip Package List (Export):
pip freeze > requirements.txt
1.2) Load pip Package List (Import):
pip install -r requirements.txt
2. Using conda:
Similarly, when using conda, you can save the package list from the previous virtual environment as follows [1) Export], and then load the package list into the new virtual environment as follows [2) Import].
2.1) Save conda Package List (Export):
conda list --export > requirements.txt
2.2) Load conda Package List (Import):
conda install --file requirements.txt
※Note: Sometimes the text file containing the package list might have a different name (e.g., "packagelist.txt"). So, when cloning code from GitHub or other sources, make sure to verify the filename beforehand.
'DataScience > 참고자료' 카테고리의 다른 글
구글 코랩(Colab) seaborn, matplotlib 한글 폰트 깨짐 현상 해결(2024.01월 버전) (0) | 2024.01.25 |
---|---|
자주 사용하는 conda 커멘드 명령어(activate, install) 정리 (0) | 2023.08.14 |
파이썬 가상환경 라이브러리 설치/내보내기(Import/Export requirements.txt) (0) | 2023.08.13 |
참고 : Ubuntu WSL 환경에서 리눅스 GUI 활용하기 (0) | 2023.07.11 |
참고 : Windows에 설치된 VirtualBox를 사용하여 Ubuntu 설치하기 (0) | 2023.07.06 |
댓글