简体   繁体   中英

Virtual Environment won't activate on Windows 10

I use Windows 10, python 3.7.4 and i've installed virtualenv with pip. When i try to create virtual environment in cmd i can create with virtualenv myenv. It creates the files needed, Scripts folder and activate files are all there. But when i try to activate nothing happens. I try:

C:\Users\Spike\pyenv>cd crawler

C:\Users\Spike\pyenv\crawler>cd scripts

C:\Users\Spike\pyenv\crawler\Scripts>activate

After this virtual environment name should be in parenthesis like this:

(crawler) C:\Users\Spike\pyenv\crawler\Scripts

but it is not, virtual env is not activated, it continues like this:

C:\Users\Spike\pyenv\crawler\Scripts>

I've tried running cmd in admin mode, doesn't work.

I've tried to activate from Powershell:

PS C:\Users\Spike\pyenv\crawler> cd scripts
PS C:\Users\Spike\pyenv\crawler\scripts> activate

But i get a error:

activate : The term 'activate' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ activate
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (activate:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

So i've tried Set-ExecutionPolicy AllSigned and Set-ExecutionPolicy Unrestricted -Force on Powershell before activating it, it also doesn't work.

I've also tried to activate it in cmder, i get the same result i got in cmd.

To solve i first looked in to other stackoverflow thread but none helped.

Check the name of your virtualenv. You said the name of your env was myenv. However, you are in the pyenv directory. If you CD to the folder you where in when you created myenv, the following should work.

myenv/Sripts/activate

If that does not work, make sure the activate file is actually there.

Also, note that in certain cases the virtualenv starts but you don't get the (myenv) bahavior. Run the following to see if the virtualenv is activated.

which python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM