PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label python-venv. Show all posts
Showing posts with label python-venv. Show all posts

Monday, November 21, 2022

[FIXED] How to auto-activate python virtual environment in Visual Studio terminal?

 November 21, 2022     python, python-venv, virtualenv, visual-studio, visual-studio-2022     No comments   

Issue

I am using Visual Studio (not Visual Studio Code) for the development of a Python application.

Is there a way to make the Visual Studio's Developer PowerShell auto-activate the virtual environment, as is possible in PyCharm or in VS-Code? Right now, I have to explicitly run the command .\env\Scripts\activate in the Terminal to activate the Virtual Environment.


Solution

I found a key in setting up PowerShell startup arguments.

Go to the Visual Studio 2022 Parameters -> Environment -> Terminal. In "Profiles" window click on PowerShell for developers (Default), then Arguments and follow next steps:

  1. Add -ExecutionPolicy RemoteSigned in the very beginning.
  2. Find -Command "&{ Command1; Command2; ...; CommandN}" syntax and add env\Scripts\activate as one of the commands (so it looks like -Command "&{ Command1; Command2; ...; env\Scripts\activate}").

Congrats! Now Visual Studio will activate your env every time you create PowerShell console.

NOTE:

-ExecutionPolicy RemoteSigned setting up ExecutionPolicy only for this particular process (...that we run every time we create PowerShell console) and does NOT affect either global, user or any other env ExecutionPolicy variable but variable in this particular process. So it is safe to set up!

P.S. We need to change ExecutionPolicy to be able to run activate script.

References:

Read more about PowerShell startup arguments and ExecutionPolicies.



Answered By - bc-ru
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, May 15, 2022

[FIXED] How to use Python3.10 on Ubuntu?

 May 15, 2022     python, python-3.x, python-venv, ubuntu     No comments   

Issue

I have installed Python 3.10 from deadsnakes on my Ubuntu 20.04 machine.

How to use it? python3 --version returns Python 3.8.10 and python3.10 -m venv venv returns error (I've installed python3-venv as well).


Solution

python3.10 --version will work.

python3-venv is for 3.8, so install python3.10-venv. For reference: deadsnakes packages for 3.10 for Focal.



Answered By - wjandrea
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing