Python Virtual Environment
In general, when developing with Python, it is usually recommended to use a virtual environment such as conda, venv, or virtualenv to avoid breaking the existing Python development environment caused by different projects introducing different versions of the same libraries. Below are examples of configuration methods for conda and venv. You can choose either one to use, but Conda virtual environment is recommended as it better supports compatibility with data analysis and other open-source libraries.
When installing via quick install commands, the miniconda virtual environment will be installed, which helps download dependencies isolated from the system Python, avoiding dependency conflicts.
Conda Virtual Environment
Follow the official installation tutorial at (https://docs.anaconda.com/miniconda/) (skip if already installed).
After installation, enter the conda environment.
On Windows, search for anaconda in the Start menu to open the conda command prompt.
Configure Mirrors (Optional)
Since downloading speed in China is slow, you can configure mirrors to speed up environment creation.
Tsinghua University Mirror
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
# Show channel URLs during searches
conda config --set show_channel_urls yes
University of Science and Technology of China Mirror
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
#设置搜索时显示通道地址
conda config --set show_channel_urls yes
Shanghai Jiao Tong University Mirror
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
Create Virtual Environment
Run the following command to create a virtual environment named cracknuts with Python version
conda create -n cracknuts python=3.12
Activate the virtual environment:
conda activate cracknuts
Then follow the installation instructions for CrackNuts.
virtualenv Virtual Environment
To use the venv virtual environment, you need Python version 3.12.0 or above installed on your system.
Install virtualenv by running:
pip install pipx
pipx install virtualenv
Create Virtual Environment
Create a folder named CrackNuts in your workspace, enter it in the command line, then run the following command to create a venv virtual environment. Replace <\path\to\Python312\python.exe> with your Python executable path.
virtualenv -p <\paht\to\Python312\python.exe> --prompt cracknuts .venv
Activate the virtual environment:
- Windows
- Linux/Mac
.venv/script/activate
source .venv/bin/activate