Home Interests Python

How to Make iPython Work in a virtualenv Virtual Environment

howchoo
howchoo   (467)
August 18, 2023
3 minutes

Share

Interests
Posted in these interests:
python • 18 guides

Trying to run iPython inside of a virtualenv virtual environment will likely result in this error:

WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.

This is a problem because my virtual environment is running Python 3.5, and iPython is using the system’s Python 2.7.

1 – Install iPython inside of your virtual environment

Make sure your virtual environment is activated. For this demo, mine is called py3.

workon py3

Now install iPython.

pip install iPython

or

pip3 install iPython

After running iPython you may still see the warning find that it’s still trying to use Python 2.7. If so, look at Step 2.

2 – Run hash -r

From your bash shell, run:

hash -r

And try running iPython again.

When you’ve run iPython previously in a shell session, that command was cached. This command simply resets the cache. And now when you run:

ipython

It will refer to the version of iPython that you installed in your virtual environment.

3 – That’s it!

You’re now running iPython.

NEXT UP

Class Vs. Instance Variables in Python 3

howchoo
howchoo   (467)
November 22, 2023

When learning object oriented programming in Python, there can be a few gotchas when it comes to distinguishing between class and instance variables. In this guide I’ll explain the difference between class and instance variables and provide examples demonstrating various use cases. 1 – Class vs. instance variables First, a quick review if you’re new

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore