Is it possible to launch python idle from a virtual environment

0 votes
I have a package that I installed from a virtual environment. if I launch Idle, that package cannot be imported since it's only available in one particular virtualenv. How can I launch Idle from a virtualenv, so that all packages from the virtualenv would be available?
Aug 8, 2019 in Python by Arvind
• 3,050 points
5,964 views

2 answers to this question.

0 votes

Assuming that you are using python 3, you can do it using following steps - 

  1. Start the virtual environment
  2. Run python -m idlelib.idle
Now you can import the required package that you want to use.
answered Aug 8, 2019 by Neel
• 3,020 points
Thank you! I have been trying to solve the same problem. The following also works while still allowing you to use the terminal:

pythonw -m idlelib.idle
0 votes

Try running the following code.

#!/usr/bin/env python
"""Simple script to run Idle from a venv in PyCharm."""

try:
    # Import for Python pre 3.6
    from idlelib.PyShell import main
except ModuleNotFoundError:
    # Import for Python version 3.6 and later
    from idlelib.pyshell import main

if __name__ == '__main__':
    main()
answered Jun 25, 2020 by Sirajul
• 59,230 points

Related Questions In Python

0 votes
1 answer
0 votes
4 answers

Is it possible to call one python script from another Python Script?

Try using os.system: os.system("script2.py 1") execfile is different because it is ...READ MORE

answered Dec 16, 2020 in Python by Gitika
• 65,770 points
70,361 views
0 votes
1 answer

Is it possible to print all the modules imported in a python script?

Since I am using Python 3.6, I ...READ MORE

answered Jul 3, 2019 in Python by Neel
• 3,020 points
3,418 views
0 votes
1 answer

is it possible to create zip of a directory in Python?

Please go through this code. This should ...READ MORE

answered Jul 10, 2019 in Python by Arvind
• 3,050 points
896 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,071 views
0 votes
1 answer

Is it possible to run a function in Python using the command line?

Suppose your file name is demo.py and ...READ MORE

answered Jun 26, 2019 in Python by Neel
• 3,020 points
1,045 views
+1 vote
1 answer

is it possible to compare a values to a backslash in Python?

The backslash "\" character is used to ...READ MORE

answered Jun 28, 2019 in Python by Neel
• 3,020 points
1,749 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP