I'm using Ubuntu 20.04 with pyenv on my console to choose the Python version.
For the following, see screenshot below.
Within VS Code, I pointed the version (1) to my pyenv version (2). It tells me that astor is not installed (3). It definitely is installed, so my run configuration is using another environment.
my launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Which environment does VS Code (with pylance) use? How can I make it use the pyenv environment? Is there another option to install the required packages in that environment?
Adding it to the extras in settings:
Installing it within the console:
Since we use " pip
" to install the module " astor
", the source of pip
used determines where the module is installed. We can use " pip --version
" or " pip3 --version
" to check the source of pip
:
Please use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, it will automatically enter the currently selected environment.
Use " pip
" to install " astor
": " pip install astor
" or " pip3 install astor
".
Check the installation package. Use " pip list
":
Result:
Other ways to install modules:
On the premise that "Anaconda" has been installed, use conda to install the module in VSCode: " conda install astor
":
For more use, you can refer to: Environment in VSCode.
Update:
Please try to reload VSCode or reopen VSCode.
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.