Issue with virtualenv - cannot activate

前端 未结 25 1870
借酒劲吻你
借酒劲吻你 2020-12-04 05:20

I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now.

You can see

相关标签:
25条回答
  • 2020-12-04 05:52

    source command is officially for Unix operating systems family and you can't use it on windows basically. instead, you can use venv\Scripts\activate command to activate your virtual environment.

    0 讨论(0)
  • 2020-12-04 05:53

    I had the same problem. I was using Python 2, Windows 10 and Git Bash. Turns out in Git Bash you need to use:

     source venv/Scripts/activate
    
    0 讨论(0)
  • 2020-12-04 05:53

    You can run the source command on cygwin terminal

    0 讨论(0)
  • 2020-12-04 05:54
    1. Open your powershell as admin
    2. Enter "Set-ExecutionPolicy RemoteSigned -Force
    3. Run "gpedit.msc" and go to >Administrative Templates>Windows Components>Windows Powershell
    4. Look for "Activate scripts execution" and set it on "Activated"
    5. Set execution directive to "Allow All"
    6. Apply
    7. Refresh your env
    0 讨论(0)
  • 2020-12-04 05:54

    If wants to open virtual environment on Windows then just remember one thing on giving path use backwards slash not forward.

    This is right:

    D:\xampp\htdocs\htmldemo\python-virtual-environment>env\Scripts\activate
    

    This is wrong:

    D:\xampp\htdocs\htmldemo\python-virtual-environment>env/Scripts/activate
    
    0 讨论(0)
  • 2020-12-04 05:55

    I have a hell of a time using virtualenv on windows with git bash, I usually end up specifying the python binary explicitly.

    If my environment is in say .env I'll call python via ./.env/Scripts/python.exe …, or in a shebang line #!./.env/Scripts/python.exe;

    Both assuming your working directory contains your virtualenv (.env).

    0 讨论(0)
提交回复
热议问题