最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - VSCode terminal uses global pip instead of venv pip - Stack Overflow

programmeradmin1浏览0评论

So yesterday i noticed that the vscode terminal was using the global pip instead of the pip in my virtual environment when trying to use pip or package commands. Running the python file is no problem. I haven't been able to fix this since.

'pip list' command from vscode terminal

Here is the same command from cmd window:

'pip list' command from command prompt

So yesterday i noticed that the vscode terminal was using the global pip instead of the pip in my virtual environment when trying to use pip or package commands. Running the python file is no problem. I haven't been able to fix this since.

'pip list' command from vscode terminal

Here is the same command from cmd window:

'pip list' command from command prompt

Share Improve this question asked Mar 12 at 16:23 Mathis H.Mathis H. 33 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

This very likely means that your vscode terminal uses also the wrong Python environment and another Python executive than your project uses.

Set the Python Interpreter in VS Code
    1.  Open VS Code.
    2.  Open the Command Palette (Cmd + Shift + p) 
                                         (or: Ctrl + Shift + p)
    3.  Search for Python: Select Interpreter.
    4.  Select “Enter interpreter path” → “Find…”.
    5.  Navigate to the Python path of your project 
                (`which python` might help to clarify that from within 
                your project's python - if you are in windows, 
                install scoop and install linux tools using scoop install).
    6.  Confirm selection.

From your screenshots it appears that you do not have a virtual environment in your Windows DOS shell. Use a Linux command line emulator such as git bash or WSL. Setup `.bash_profile` with the following … source /.venv/bin/activate. To create a venv `python3 -m venv .venv `. In addition, you need to tell Code which interpreter to use. This is found here Selecting python interpreter in VSCode

发布评论

评论列表(0)

  1. 暂无评论