I've attempted to read the IPython 0.13 docs, but I've been unable to figure out how to get IPython to default to interactive mode.
Back in IPython 0.10, I could type:
ipython <some_script.py>
and the script would run and drop me to the interactive prompt.
Today, with 0.13, I must add the -i command-line option:
ipython -i <some_script.py>
Can someone please share the ipython config file option that would make IPython 0.13 go directly to interactive mode after running a script?
create default IPython config files first, if you haven't already
ipython profile create
add this line to profile_default/ipython_config.py (you can find profile_default with ipython locate profile)
c.TerminalIPythonApp.force_interact = True
Which is the value that -i sets at the command-line.
With this config, it will be as if you always type ipython -i.
Related
I am trying to use the interactive shell of IPython within my conda env and am having issues.
The steps I take are:
source activate myenv
conda install ipython
ipython
When I am in ipython interactive shell, it calls python from the anaconda root bin. (~/anaconda2/bin')
Is there anything I can do to change the python path to ~/anaconda2/envs/myenv/bin and import packages from myenv?
I see few solutions to making env work in jupyter when I search the web, but no answer on making it work on the interactive shell.
This is likely due to your $PATH variable being messed up.
THe easiest way to make sure you get IPython from within an env is to use $ python -m IPython <rest of the options> to start IPython. This works for many of the Python installable application; like pytest, pip and other.
I have installed Anaconda for my Machine Learning course. I'm using it as IPython (Jupyter) notebook, in which we have lessons. OS is Ubuntu 14.04 LTS. Basically, I always run it from Terminal with:
jupyter notebook
I have created new environment called su_env from root environment (exact copy) with one package added. Now, I'm wondering: how can I set environment su_env as default one? I have dozen of notebooks so it's annoying to set up each time for every notebook the environment, in "web" GUI of Jupyter.
EDIT: I'm interested in a solution where you don't have to set environment before running notebook. My logic is that, somehow, automagically, jupyter sets root environment on its own while starting up. Because of that, I'm wondering is it possible to set some config file or something so jupyter sets su_env instead of root. Also, if you know that's not possible (and why), I would like to know that.
First activate the conda environment from the command line, then launch the notebook server.
For example:
$ source activate env_name
$ jupyter notebook
Note: This might only work with environments that were created from within Jupyter Notebook, not environments that were created using conda create on the command line.
In your ~/.bashrc, include the line:
alias jupyter="source activate su_env; jupyter"
This will condense the two commands into one, and you will activate su env whenever you call jupyter notebook or lab or whatever
Edit your bashrc and add source activate su_env then that env will always be active. To switch back to to root (or any other env) source activate env_name
You can use this on conda prompt:
conda activate env_name
jupyter notebook
source activate env_name gives me an error: 'source' is not recognized as an internal or external command, operable program, or batch file.
I am having a really hard time adding python 2.7 as a kernel to my iphyton notebook. I have anaconda installed with a python environment called "python2." I can navigate to the environment folder and launch ipython (using python 2.7) in the script folder.
I have tried ipython kernelspec install-self using iphython.exe, however, it seems like ipython is not even a command in that window.
I tried it again in anaconda command window and it just install python3. Please help with precise steps.
Ok I got it. I had to:
Change my python.exe under envs to python2.exe. I also change pythonw to pythonw2.
Added Anacoda\envs\python2 folder that includes python2.exe and scripts to path variable
Then ran this command in Anaconda command window: python2 -m IPython kernelspec install-self
Then ipython kernelspec list to verify
When I launch ipython notebook, I want it to launch firefox but using a particular firefox profile, which is not my default firefox profile.
In my ipython profile, I have
c.NotebookApp.browser = u'/usr/bin/firefox'
and that makes sure that ipython notebook chooses firefox. However, it chooses the default firefox profile, or else the most recently used firefox profile.
From my linux terminal, I can launch my preferred ipython specific firefox profile (named ipython) like this
firefox -P --no-remote ipython
However, doing
c.NotebookApp.browser = u'/usr/bin/firefox -P --no-remote ipython'
does not work at all (ipython doesn't open firefox at all, and skips to the another browswer'), nor does starting ipython notebook like so
ipython notebook --browser 'firefox -P --no-remote ipython'
which leads to and OSError exception.
Does anyone know of a way to launch firefox with the preferred profile?
A little ugly but maybe better than nothing. I put the following into a shell script to launch firefox and ipython separately but at the same time i.e.
firefox -P ipython -no-remote
ipython notebook --no-browser
You will need to refresh the browser.
My solution uses a script to start firefox with the requested profile and makes Jupyter call it.
Create a script in e.g. /usr/local/bin/firefox-notebook with the following content:
!/bin/env sh
firefox -P notebook $#
Instruct Jupyter to use that script as a browser by adding the following in your jupyter_notebook_config.py:
import webbrowser
browser = webbrowser.Mozilla('firefox-notebook')
webbrowser.register('firefox-notebook', None, browser)
c.NotebookApp.browser = 'firefox-notebook'
You can simply add c.NotebookApp.browser = 'firefox -P notebook --new-window %s' to ~/.jupyter/jupyter_notebook_config.py. (You missed the %s. It will be replaced by the URL at which jupyter is served.)
Which command is the equivalent of
ipython profile create
when I normally start ipython via
python -m IPython
(i.e. I did not install IPython, just unzipped it and adapted PATH and PYTHONPATH)?