Python Forum
Keeping up with IDEs and Virtual Environments...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keeping up with IDEs and Virtual Environments...
#4
(Sep-04-2022, 03:35 PM)bytecrunch Wrote: I think I am missing a piece about virtual environments: we don't use pip to add a Python interpreter to the virtual environment. So how do we connect a specific Python interpreter version to a virtual environment? What are the commands?
You are talking about venv that comes with Python?
Usually use the lasted version have on OS,but can use any version that is installed.
Example:
G:\div_code
λ python -V
Python 3.10.5

G:\div_code
λ python -m venv new_env

G:\div_code
λ cd new_env\

G:\div_code\new_env
λ G:\div_code\new_env\Scripts\activate

(new_env) G:\div_code\new_env
λ python -V
Python 3.10.5 
Let say i want to use Python 3.7 that have installed,then can use py(comes with Python).
G:\div_code
λ py -3.7 -V
Python 3.7.3

G:\div_code
λ py -3.7 -m venv new_env

G:\div_code
λ cd new_env\

G:\div_code\new_env
λ G:\div_code\new_env\Scripts\activate

# Environment will now use 3.7
(new_env) G:\div_code\new_env
λ python -V
Python 3.7.3
There are 3-party packages that can install a new Python version to a environment(not on OS) like Anacondas conda ,
or Poetry with pyenv on Linux.
Poetry is really good so worth to take a look.

Quote:Ok on IDEs non coming with an interpreter. I guess the IDLE did when I downloaded it.
No,but PyCharm will usually find any Python version if there is any on the OS.
Look at Configure a Python interpreter PyCharm
There see how to choice an exiting interpreter or virtual environment.
Reply


Messages In This Thread
RE: Keeping up with IDEs and Virtual Environments... - by snippsat - Sep-04-2022, 05:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best practice on using virtual environments in Python bytecrunch 6 1,487 Feb-14-2024, 03:22 PM
Last Post: snippsat
  Virtual Environments - Organization (VS Code) JaysonWonder 11 2,152 Jan-26-2023, 11:34 PM
Last Post: Larz60+
  I don't understand pip and environments snakes 3 1,383 Jul-31-2022, 08:17 PM
Last Post: snakes
  Keeping a value the same despite changing the variable it was equated to TheTypicalDoge 2 1,615 Mar-13-2022, 10:50 PM
Last Post: Yoriz
  Use different Anaconda environments on Linux Mint and Spyder StaLLoNe_CoBRa 0 1,966 Jan-20-2021, 03:12 AM
Last Post: StaLLoNe_CoBRa
  pip and venv virtual environments soupworks 2 2,395 Dec-30-2020, 11:38 PM
Last Post: soupworks
  Traceback error in PyCharm but not in other IDEs? devansing 7 6,673 Mar-05-2020, 11:27 AM
Last Post: buran
  Problem keeping the window up benlyboy 11 4,448 Jan-24-2020, 02:12 AM
Last Post: tamilselvisubbiah
  Virtual Environments pneveux 1 1,923 Apr-04-2019, 09:15 PM
Last Post: Larz60+
  merging lists, dedup and keeping order, in older pythons Skaperen 3 3,301 Oct-19-2018, 01:30 AM
Last Post: ODIS

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020