vscode command line environment settings

Problem Description

在vscode中想用命令行执行代码:

python train.py --gpu_ids 0 --name ft_ResNet50 --train_all --batchsize 32  --data_dir your_data_path

The result is shown as follows:
insert image description here
The vscode operating environment is correct, there is torch in this environment, but the command line shows that there is no torch in the current environment.
insert image description hereinsert image description here

Cause Analysis:

try 1

I try to enter directly on the vscode command line and
python
the result is as follows. This python3.8 is in the base environment (my pytorch environment python version is 3.9)

insert image description here

try 2

I thought that my environment should be different, so I tried to activate the environment on the command line.
conda activate pytorch_gpu
Trying to enter again
python
failed. The result is still the python version in the base environment.


solution:

The problem is whether the terminal is shell or cmd

insert image description here
Select cmd in this place, and the command line appears as follows.
insert image description here
That's it, the name of the environment appears in front of it.

Guess you like

Origin blog.csdn.net/qq_42911863/article/details/127276219