简体   繁体   中英

how to include specific Anaconda python package in VSCode

I downloaded and installed GDAL through Anaconda Environments button at the left hand side of home page. It works in Anaconda Jupyter Notebook.

Currently I did from osgeo import ogr in VSCode, and the terminal says ModuleNotFoundError: No module named 'osgeo' .

I wish to import it too in VSCode. Then how to do it?

Thank you.

I create a virtual environment called onda in Anaconda and download GDAL in onda . The point is that you should select the environment where you install the package as your interpreter:

在此处输入图片说明

Here is the solution:

1.Add Anaconda to environment path, including:

---\\Anaconda3\\Scripts

---\\Anaconda3

2.Activate conda in powershell, run powershell as administrator and type the command:

1. conda install -n root -c pscondaenvs pscondaenvs

2. Set-ExecutionPolicy RemoteSigned

3.In VS Code, use the command conda activate env_name to activate and enter the environment;

If you didn't create virtual environment, the package gdal was default installed in base environment, so use conda activate base . Try to run python file in Terminal again.

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