简体   繁体   中英

how to activate virtualenv in vs code editor when i type source env/bin/activate it does not activate

Note: I have newly installed vs code in window 10

PS C:\Users\admin\Desktop\Kiit Project\django-ecommerce> source env/bin/activate
source : The term 'source' 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.
+ source env/bin/activate
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (source:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Suppose the name of your virtual environment is env , you can simply go into the directory(I think C:\Users\admin\Desktop\Kiit Project\django-ecommerce in your case) where it is and run env\Scripts\activate . This should do the work.

However, in VScode you might have to edit the settings.json file present in .vscode folder and add the following:

{
    ...
    "python.pythonPath": "C:\Users\admin\Desktop\Kiit Project\django-ecommerce\env\bin\python",
    ...
}

If you are not able to find the settings.json file mentioned above, simply press Ctrl+Shift+P and type python Select Interpreter and press Enter . You will then see a .vscode directory containing your settings.json file.

You can edit this file however you'd like to change the Python interpreter to be used for VScode instance.

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