ranni rabadi
ranni rabadi

Reputation: 324

Open Python IDLE in current virtual environment

Using the Windows command line, how can I open a Python file inside the current virtual environment that I am in?

For example, say I'm in my virtual environment:

(env) C:\MyFolder>

and then I want to open my Python file:

(env) C:\MyFolder>mypythonfile.py

The .py file will open in IDLE but not inside the (env) environment

Upvotes: 1

Views: 3262

Answers (1)

Sophie
Sophie

Reputation: 31

To achieve this via 3 steps:

Suppose that you are using windows system and have open a cmd window.

  1. Activate your virtual environment: venv/Scripts/activate (venv is the path of your virtual environemnt)

You could use this command "where python" to check if your virtual environment is activated. If success, it should point to your virtual environment path at the first line.

  1. Launch idle within your virtual environment: python -m idlelib.idle

A IDLE window should be popped up. You can check if this is within the virtual environment by import a package only installed in the virtual environment but not in the local python.

  1. Now from the idle open the file that you want to edit: Click 'File - Open' in sequence, and then choose the file.

Now you can just try to press 'F5', you will see this file would be run in the virtual idle.

Upvotes: 2

Related Questions