5

I've got a python project for which I'm using VS Code on Windows. I created a virtual environment (py -3 -m venv .venv). This all seems to be fine. When I activate (.\.venv\Scripts\Activate.ps1 or .\.venv\Scripts\activate.bat) I see (.venv). I can run pip in the activated environment or not. However, when I open a .py file there is a warning that there is no linter installed. I click install and then I get this:

no Pip installer available error message

I've tried creating the virtual env different ways. I've tried this answer. No matter what I do I always get that error message. Any ideas would be great.

devlife
  • 15,275
  • 27
  • 77
  • 131
  • 1
    Something similar happened to me recently. It turned out that I had two versions of python installed (2.7 and 3.6) and I forgot to update the project's default interpreter. Not sure if this is your problem, but thought I'd mention it. CTRL+SHIFT+P -> Select Interpreter – Andrew L Feb 27 '19 at 03:11
  • Yup I did indeed do that but it still didn't work until I used the link in the answer. – devlife Mar 09 '19 at 00:13

3 Answers3

4

Wow after about 3 hours of banging my head I found the answer here: http://timmyreilly.azurewebsites.net/python-pip-virtualenv-installation-on-windows/

Using that guide instead of the official vs code docs (where I got the py -3 -m venv command), VS Code was able to work properly.

devlife
  • 15,275
  • 27
  • 77
  • 131
2

From VSCode: There is no Pip installer available in the selected environment

I have multiple python versions:

  • 2.7
  • 3.6
  • 3.7

Tell the vscode/ visual studio code, which version to use: press the following (Show All Commands): Ctrl + Shift + P paste the following: Python: Select Interpreter Select one of the version that it shows, I have selected python 3.7.3 64-bit

Update python path in settings: press Ctrl + , to open Settings search for python.pythonPath change python to /usr/bin/python3.7

Note: For windows you will need to find your python path. Mine was C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python37_64

I had pip but it was 2.7, but since I am choosing python 3, it's pip needs to be installed Run the following command in Terminal: apt-get install python3-pip

I didn't have to install python pip as it was already installed.

Restart vscode With the above steps, all issues got resolved. Hope that helps.

Rey
  • 186
  • 5
1

I've experienced the same issue. While I don't know what causes it, I've found that creating the virtual environment using the Windows command prompt (using e.g. py -3 -m venv .venv) rather than via a terminal in VS Code successfully creates an environment that includes pip - then I can return to VS Code and work with it without issue.

philipnye
  • 352
  • 1
  • 3
  • 16