Show More
@@ -0,0 +1,8 b'' | |||||
|
1 | New setting to silence warning if working inside a virtual environment | |||
|
2 | ====================================================================== | |||
|
3 | ||||
|
4 | Previously, when starting IPython in a virtual environment without IPython installed (so IPython from the global environment is used), the following warning was printed: | |||
|
5 | ||||
|
6 | Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv. | |||
|
7 | ||||
|
8 | This warning can be permanently silenced by setting ``c.InteractiveShell.warn_venv`` to ``False`` (the default is ``True``). |
@@ -479,6 +479,11 b' class InteractiveShell(SingletonConfigurable):' | |||||
479 | """ |
|
479 | """ | |
480 | ).tag(config=True) |
|
480 | ).tag(config=True) | |
481 |
|
481 | |||
|
482 | warn_venv = Bool( | |||
|
483 | True, | |||
|
484 | help="Warn if running in a virtual environment with no IPython installed (so IPython from the global environment is used).", | |||
|
485 | ).tag(config=True) | |||
|
486 | ||||
482 | # TODO: this part of prompt management should be moved to the frontends. |
|
487 | # TODO: this part of prompt management should be moved to the frontends. | |
483 | # Use custom TraitTypes that convert '0'->'' and '\\n'->'\n' |
|
488 | # Use custom TraitTypes that convert '0'->'' and '\\n'->'\n' | |
484 | separate_in = SeparateUnicode('\n').tag(config=True) |
|
489 | separate_in = SeparateUnicode('\n').tag(config=True) | |
@@ -847,11 +852,11 b' class InteractiveShell(SingletonConfigurable):' | |||||
847 | p_ver = re_m.groups() |
|
852 | p_ver = re_m.groups() | |
848 |
|
853 | |||
849 | virtual_env = str(virtual_env_path).format(*p_ver) |
|
854 | virtual_env = str(virtual_env_path).format(*p_ver) | |
850 |
|
855 | if self.warn_venv: | ||
851 | warn( |
|
856 | warn( | |
852 | "Attempting to work in a virtualenv. If you encounter problems, " |
|
857 | "Attempting to work in a virtualenv. If you encounter problems, " | |
853 | "please install IPython inside the virtualenv." |
|
858 | "please install IPython inside the virtualenv." | |
854 | ) |
|
859 | ) | |
855 | import site |
|
860 | import site | |
856 | sys.path.insert(0, virtual_env) |
|
861 | sys.path.insert(0, virtual_env) | |
857 | site.addsitedir(virtual_env) |
|
862 | site.addsitedir(virtual_env) |
General Comments 0
You need to be logged in to leave comments.
Login now