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

no need to activate pipenv #3743

Closed
BMBurstein opened this issue Dec 18, 2018 · 5 comments
Closed

no need to activate pipenv #3743

BMBurstein opened this issue Dec 18, 2018 · 5 comments
Labels
feature-request Request for new features or functionality

Comments

@BMBurstein
Copy link

Environment data

  • VS Code version: 1.30.0
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pipenv

Expected behaviour

When selecting a pipenv virtual environment, if pylint is not installed, vscode asks if to install it. If selecting yes, vscode will attempt to activate the virtual env and then install pylint. With pipenv, activating is not needed, and indeed not recommended. Just running pipenv install is the correct action.

Output from my terminal window:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Home\Documents\vscode\flask_pg> & C:/Users/Home/.virtualenvs/flask_pg-Zt94nPwC/Scripts/activate.ps1
& : File C:\Users\Home\.virtualenvs\flask_pg-Zt94nPwC\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ & C:/Users/Home/.virtualenvs/flask_pg-Zt94nPwC/Scripts/activate.ps1
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

PS C:\Users\Home\Documents\vscode\flask_pg> & pipenv install pylint --dev
Installing pylint…
Adding pylint to Pipfile's [dev-packages]…
Installation Succeeded
Pipfile.lock (7fbb99) out of date, updating to (662286)…
Locking [dev-packages] dependencies…
Success!
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (7fbb99)!
Installing dependencies from Pipfile.lock (7fbb99)…
  ================================ 14/14 - 00:00:04
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
@d3r3kk d3r3kk added feature-request Request for new features or functionality feature-* labels Dec 18, 2018
@d3r3kk
Copy link

d3r3kk commented Dec 18, 2018

Interesting, and thanks for the report @BMBurstein.

The failure I see above is actually a known issue to do with the initial install of Powershell (see #2559) - when you use Powershell as your console provider in VS Code, you can experience exactly this failure on a new Windows install. You can work around this specific problem by opening a Powershell window as administrator and typing the command:

Set-ExecutionPolicy RemoteSigned -Force

...and then close and restart all instances of VS Code. (Another workaround is to set your default shell to something other than Powershell).

As for the install process, your comment seems to pose a difference in how Pipenv works as opposed to other Python virtual environments. We handle all environments (in a sense) the same, and that is indeed why we are attempting to activate, then install. However, I think it would be possible to do this a different way, as how we install things is separate and can be made more specific per environment if I am not mistaken (@DonJayamanne is that correct?)

I am leaving this open as a feature enhancement that we can decide on for the next few sprints.

@DonJayamanne
Copy link

I am leaving this open as a feature enhancement that we can decide on for the next few sprints.

Agreed. The underlying problem is the fact that the environment isn't being activated due to PS permissions.

@BMBurstein

With pipenv, activating is not needed, and indeed not recommended.

You can always disable environment activation globally or for this specific workspace. Just open your user or workspace settings.json and add the following setting:
"python.terminal.activateEnvironment": false,

@BMBurstein
Copy link
Author

I understood that the activation failed due to some other issue, and I was not reporting it here since it was irrelevant to the actual issue. As you can see the installation worked anyway, since activation is not needed when using pipenv.
As an aside, another difference between pipenv and other virtual environments is that if you do want to activate it, the correct way is to run pipenv shell, not by calling the activate script.

@BMBurstein
Copy link
Author

@BMBurstein

With pipenv, activating is not needed, and indeed not recommended.

You can always disable environment activation globally or for this specific workspace. Just open your user or workspace settings.json and add the following setting:
"python.terminal.activateEnvironment": false,

I didn't realize that the activation was part of the terminal launching. I thought it was part of the pylint installation.

@DonJayamanne
Copy link

Dup of #2855

@ghost ghost removed the needs decision label Jan 8, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants