简体   繁体   中英

Visual Studio Code, Anaconda Virtual Environment, specific projects?

can anyone help me understand using conda environment with visual studio code? I had activate the virtual environment (imageprocessing) with this:

conda activate imageprocessing

and the terminal seem to have been on virtual environment, so there's look like no problem with the PATH, it looks like this.

(imageprocessing) ../users/[project_folder_somewhere]

But when I open visual studio code and activate the kernel used for opening Notebooks there, exactly with the python from imageprocessing virtual environment, I keep needed to install the previously forged library, for example, Pillow. Which part that doesn't work out? Did I install Pillow package redundantly if I keep doing this? Does visual code doesn't integrated that well with conda even though it has been connected through the path? I used this feature for opening.ipynb files on Visual Studio Code because browser-based Jupyter Notebooks are too slow and messy directory than if using this (or so I thought?).

In VS Code, when we use different python environments, the locations where the modules are installed are different. Therefore, we need to be clear which python environment we are currently using. (We could check it with the command " python --version " in the VS Code terminal.)

When we use the conda environment, it comes with python, so we can use "pip" to install modules, or "conda" to install modules. The modules it installs are stored in: " ...\anaconda3\envs\conda-name\lib\site-packages ".

The command " pip show pillow " checks the installation position of the module:

在此处输入图像描述

In addition, after the installation is complete, it still shows that the module cannot be found. I noticed that there is a problem with the file name here. We need to rename "PIL" to "pillow", or use "import PIL"

在此处输入图像描述

Reference: conda-environment in VS Code .

Add:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM