Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv. #14327

Closed
guettli opened this issue Oct 8, 2020 · 18 comments · Fixed by #19247
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@guettli
Copy link

guettli commented Oct 8, 2020

Environment data

Version: 1.49.3
Commit: 2af051012b66169dde0c4dfae3f5ef48f787ff69
Date: 2020-10-02T17:56:11.027Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.4.0-48-generic snap

Steps to reproduce:

python3 -m venv myenv
cd myenv
. bin/activate
code .

Then in vscode I get asked if I would like to install pylint. I click on "yes".

The the error happens (this code was created/executed by vscode):

guettli@yoga15:~/projects/myenv$ source /home/guettli/projects/myenv/bin/activate
(myenv) guettli@yoga15:~/projects/myenv$ /home/guettli/projects/myenv/bin/python /home/guettli/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py pip install -U pylint --user
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

Expected behaviour

Since the interpreter is in a virtualenv, it would make sense to avoid --user.

@guettli guettli added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Oct 8, 2020
@karthiknadig karthiknadig self-assigned this Oct 12, 2020
@karthiknadig karthiknadig added important Issue identified as high-priority triage labels Oct 12, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Oct 12, 2020
@karthiknadig karthiknadig added the area-environments Features relating to handling interpreter environments label Oct 12, 2020
@karthiknadig
Copy link
Member

I can repro this.

@karthiknadig karthiknadig removed their assignment Oct 13, 2020
@luabud luabud added important Issue identified as high-priority and removed important Issue identified as high-priority labels Oct 21, 2020
@luabud luabud removed the important Issue identified as high-priority label Oct 28, 2020
@jkirk
Copy link

jkirk commented Nov 15, 2020

As described in vscode#43347 setting python.globalModuleInstallation": true (Python: Global Module Installation) works for me as workaround.

@guettli
Copy link
Author

guettli commented Dec 2, 2020

Pip can install software in three different ways:

  1. At global level. I would avoid it
  2. At user level
  3. At virtualenv level. This is (at least for me) the preferred one.

I don't think "python.globalModuleInstallation": true is a good solution.

Virtualenv is great, and disk space is cheap.

@kevr
Copy link

kevr commented Dec 17, 2020

Pip can install software in three different ways:

1. At global level. I would avoid it

2. At user level

3. At virtualenv level. This is (at least for me) the preferred one.

I don't think "python.globalModuleInstallation": true is a good solution.

Virtualenv is great, and disk space is cheap.

It can install in two ways: global or at the user level. It's just that virtualenvs put you in a new root for python, so you end up installing globally. However, it would be nice if it was detected that the user was using a virtualenv, with modifiable flags, so we could change the default value of that parameter depending on the case.

@jwalahe
Copy link

jwalahe commented Jan 10, 2021

#14327
I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

  1. Go to the pyvenv.cfg file in the Virtual environment folder
  2. Set the include-system-site-packages to true and save the change
  3. Reactivate the virtual environment.
    This should work!

@jeffmaddocks
Copy link

#14327
I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

1. Go to the `pyvenv.cfg` file in the Virtual environment folder

2. Set the `include-system-site-packages` to `true` and save the change

3. Reactivate the virtual environment.
   This should work!

worked perfectly for me, thanks!

@medo962006
Copy link

#14327
I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

1. Go to the `pyvenv.cfg` file in the Virtual environment folder

2. Set the `include-system-site-packages` to `true` and save the change

3. Reactivate the virtual environment.
   This should work!

worked perfectly for me, thanks!

'Great!

@ucaslyy
Copy link

ucaslyy commented May 26, 2021

Pip can install software in three different ways:

1. At global level. I would avoid it

2. At user level

3. At virtualenv level. This is (at least for me) the preferred one.

I don't think "python.globalModuleInstallation": true is a good solution.
Virtualenv is great, and disk space is cheap.

It can install in two ways: global or at the user level. It's just that virtualenvs put you in a new root for python, so you end up installing globally. However, it would be nice if it was detected that the user was using a virtualenv, with modifiable flags, so we could change the default value of that parameter depending on the case.

Great! It works properly. thanks!

@JReeGene
Copy link

JReeGene commented Jun 2, 2021

#14327
I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

1. Go to the `pyvenv.cfg` file in the Virtual environment folder

2. Set the `include-system-site-packages` to `true` and save the change

3. Reactivate the virtual environment.
   This should work!

worked perfectly for me, thanks!

This also worked for me. Thanks a lot!

@m666m
Copy link

m666m commented Jul 25, 2021

same problem in my vscode 1.47.3,pylance。
use “ pip install xxx ” successed。

In virtualenv, don't use "pip install xxx --user"

@bitsnaps
Copy link

bitsnaps commented Aug 8, 2021

#14327
I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

  1. Go to the pyvenv.cfg file in the Virtual environment folder
  2. Set the include-system-site-packages to true and save the change
  3. Reactivate the virtual environment.
    This should work!

It didn't work for me!
I was trying to git commit -m "..." using python v3.8.11 and cloud vscode.

@PrayogaBoedihartoyo
Copy link

#14327 I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

1. Go to the `pyvenv.cfg` file in the Virtual environment folder

2. Set the `include-system-site-packages` to `true` and save the change

3. Reactivate the virtual environment.
   This should work!

this work for me. .
thanks

@rashidmahmoodsyed
Copy link

For me, it was the python version issue. I was using using a version not supported by Pycaret yet. I created a clean new virtual env using supported Pycaret and it worked right away

@Guemann-ui
Copy link

Just run cmd as administrator

@ferneyvanegas
Copy link

#14327 I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

  1. Go to the pyvenv.cfg file in the Virtual environment folder
  2. Set the include-system-site-packages to true and save the change
  3. Reactivate the virtual environment.
    This should work!

It works perfect for me! Thanks!!

@dishang-trilogy
Copy link

#14327 I was trying to upgrade 'pip' in my virtual environment. I got the same error.

One quick fix is :

  1. Go to the pyvenv.cfg file in the Virtual environment folder
  2. Set the include-system-site-packages to true and save the change
  3. Reactivate the virtual environment.
    This should work!

How do you freeze it after the install?

pip install -r requirements.txt
pip freeze

The freeze is not picking up the packages from requirements.txt

@TahirMurtaza
Copy link

TahirMurtaza commented Jun 30, 2022

@guettli Using sudo before command fixes the issue:
sudo pip install package-name

@guettli
Copy link
Author

guettli commented Jun 30, 2022

@guettli Using sudo before command fixes the issue: sudo pip install package-name

thank you for trying to help. In this case I have a conrete goal.

At the top of this issue:

python3 -m venv myenv
cd myenv
. bin/activate
code .

I want packages to get installed in my virtualenv, not at root-level via sudo.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.