how to call an ipython within virtualenv?
Question:
Good time of the day, everyone!
The problem is the following:
- I create
virtualenv
using the command python3 -m venv env
(my python version 3.8.9
)
- I activate it
. ./env/bin/activate
- Install ipython:
pip install ipython
- Try to run it
ipython
, but instead of invoking my virtualenv’s ipython, My system ipython open with the following message:
/opt/homebrew/lib/python3.9/site-packages/IPython/core/interactiveshell.py:852: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn(
What should I do to change this behaviour and to be able to call my virtualenv’s ipython?
Thanks in advance!
Answers:
You can use alias to indicate ipython in your virtual env. First make sure you have activated your virtualenv source ./env/bin/activate
. Then run:
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
This is a great way of always being sure that the ipython instance always belongs to the virtualenv’s python version. And This works only on ipython >2.0.
Source: Link
Good time of the day, everyone!
The problem is the following:
- I create
virtualenv
using the commandpython3 -m venv env
(my python version3.8.9
) - I activate it
. ./env/bin/activate
- Install ipython:
pip install ipython
- Try to run it
ipython
, but instead of invoking my virtualenv’s ipython, My system ipython open with the following message:
/opt/homebrew/lib/python3.9/site-packages/IPython/core/interactiveshell.py:852: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn(
What should I do to change this behaviour and to be able to call my virtualenv’s ipython?
Thanks in advance!
You can use alias to indicate ipython in your virtual env. First make sure you have activated your virtualenv source ./env/bin/activate
. Then run:
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
This is a great way of always being sure that the ipython instance always belongs to the virtualenv’s python version. And This works only on ipython >2.0.
Source: Link