Skip to content

bug: "pyenv.ps1 is not digitally signed" and "Security warning" #332

Closed

Description

@davetapley

Describe the bug

I got a pyenv.ps1 is not digitally signed then a Security warning error after installing via zip file to C:\pyenv (not sure if path is related).

To Reproduce
Steps to reproduce the behavior:

  1. Follow With zip file in the docs

  2. Use C:\pyenv-win-master\pyenv-win instead of $HOME/.pyenv/
    (as workaround for bug: Requests hang indefinitely when using IIS with venv #321)

  3. Run pyenv

  4. See pyenv: File ... cannot be loaded... error (see Screenshots)

  5. Use Set-ExecutionPolicy workaround (see Additional context)

  6. Run pyenv

  7. See Security warning error (see Screenshots)

  8. Use Unblock-File workaround (see Additional context)

  9. Run pyenv and it works.

Expected behavior

Don't need to use Set-ExecutionPolicy and Unblock-File workarounds.

Screenshots

pyenv: File C:\pyenv-win-master\pyenv-win\bin\pyenv.ps1 cannot be loaded. The file C:\pyenv-win-master\pyenv-win\bin\pyenv.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\pyenv-win-master\pyenv-win\bin\pyenv.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"):

Desktop (please complete the following information):

  • OS: [e.g. Windows 7]
  • Tools used [e.g. command prompt, git bash]
  • Version [e.g. 22]

Additional context

Running these as a workaround for now:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Unblock-File (Join-Path $env:PYENV 'bin' 'pyenv.ps1')

Activity

  1. biofsphere commented on Nov 22, 2021

    @biofsphere

    Same here. Had to set execution policy to Unrestricted in order for pyenv to run. Installed using choco.

  2. kbumsik commented on Nov 23, 2021

    @kbumsik

    I am affected too.

    PS C:\Users\kbumsik> pyenv
    pyenv : File C:\Users\kbumsik\.pyenv\pyenv-win\bin\pyenv.ps1 cannot be loaded. The file
    C:\Users\kbumsik\.pyenv\pyenv-win\bin\pyenv.ps1 is not digitally signed. You cannot run this script on
    the current system. For more information about running scripts and setting execution policy, see
    about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:1
    + pyenv
    + ~~~~~
        + CategoryInfo          : SecurityError: (:) [], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess
    

    I got this error when running it in Powershell. Running pyenv on Command Prompt seems fine.

  3. hotenov commented on Feb 20, 2022

    @hotenov
    Member

    This is not a pyenv-win issue. This is PowerShell feature =)

    If you follow the Microsoft link in the error description you'll find valuable information about resolving this error 😇

    Long story short, execute this command in PowerShell:

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    You can experiment with another policies and scopes (if you wish), but I think mentioned in command will be enough for using pyenv

    UPD: it's worth to mention that you (maybe) need to RESTART POWERSHELL WINDOW
    UPD2: Oh, sorry! I missed that reporter tries to install 'pyenv-win' to custom folder on system disc. Probably, in that case command from commenter below is really needed (or try less restricted policy and check that you added this custom folder to User PATH)

  4. adejones commented on Feb 25, 2022

    @adejones

    Just to add to the comment above, you need both statements:

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    Unblock-File (Join-Path $env:PYENV 'bin/pyenv.ps1')

    [note the syntax in the Unblock-File statement is slightly different to OP's]

  5. fhillipgcastillo commented on Apr 4, 2022

    @fhillipgcastillo

    This doesn't directly fix the issue. But this is like a quick solution to be able to work while somebody else gives a permanent solution.

    So, the only way I was able to run pyenv was by manually writing pyenv.bat, that way it works as normal, but if I run pyenv it gives the same error.

    While having the same problem What I noticed was, when we include the bin folder into the paths, that makes up able to run anything inside that bin folder, so when we run 'pyenv' it will look into all the Window's path folder and try to run or execute any file with that name, so when we run pyenv windows tries to execute anything with that name, so what it picks as first is the .ps1 intead of the .bat file which is there. I know if there was a .exe will be the default but idk why it's picking the ps1 first.

  6. its-prithvi-raj commented on Apr 30, 2022

    @its-prithvi-raj

    Thanks a lot, @adejones !! It did wonders!

  7. kirankotari commented on May 30, 2022

    @kirankotari
    Member

    Hi All, I have updated this information in README file and given a reference to this issue for more information. This will help new users.

    I am closing this issue.

  8. quoclam-doit commented on May 20, 2023

    @quoclam-doit

    'Set-ExecutionPolicy' is not recognized as an internal or external command,
    operable program or batch file.

    Please help me the result status and i don't know what happend

  9. steve15963 commented on Aug 5, 2026

    @steve15963

    I think this command is safer.
    The execution policy resets as soon as you close the terminal session,
    keeping your system safe.

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions