Can IHaskell and IPython coexist? - ipython

I have IPython and IPython Notbook installed and am working my way through the IHaskell installation instructions. I have all the IHaskell prerequisites installed, but before I commit to the final step of installing IHaskell itself with
cabal install ihaskell --reorder-goals
I want to confirm one — perhaps obvious — thing: Will I still be able to use Python Notebooks? The instructions following the step above seem to say that simply entering
ipython notebook
will run Haskell rather than Python, as if Haskell has replaced Python in IPython Notebooks. Is this the case? How do I specify whether I want to run Haskell or Python in a notebook, or in IPython itself for that matter? Can I switch freely between the two?
OS X 10.10.4; Xcode 6.4; CLT: 6.4.0.0.1; Clang: 6.1; Haskell Platform 7.10.2-a. Python 2.7.10 (Homebrew). Using Homebrew in general, but, following what appears to be Homebrew's recommendation, not for Haskell.

Like other kernels, IHaskell can be added to IPython/Jupyter without interfering with other kernels. Once added Notebooks will recognize the language used in (suitably tagged) notebooks and will add an entry to the 'New' notebook menu that allows selection of the language to be used for new notebooks.
Each kernel will have its own command for adding itself to IPython/Jupyter. For IHaskell this is simply
ihaskell install

Related

Can't import plotly in Notebook in Visual Studio Code

I'm trying to create graphs using plotly for the first time. Since I'm currently using Visual Studio Code for my coding (either python scripts or notebooks), I'm currently trying to use plotly in VSC.
I've installed everything from the plotly getting started page (conda installed plotly, notebook, ipywidgets and even jupyter) but I'm still getiing an error when importing.
The thing is, when I've tried importing plotly in a python file in VSC, it's running well. I've also tried running it in a Jupyter Notebook and it's also running.
import plotly.express as px
I'm pretty sure that I've installed everything in the correct environment and I'm using the same environment all throughout.
What do I need to run plotly in a notebook in VSC?
It seems like your python versions/pip versions are different (especially if you're using an env). In Visual studio Code, you can bring up a simple terminal directing to the directory of your project (or env). Just click Terminal > New terminal. This will bring up a terminal (like CMD or terminal) at the bottom of the screen.
From then you can check the version of Pip and python for either your system globally, or the version install in your env. As long as your env is activated, then it will check the versions for the env, not your system.
For macOS:
To show all python installations of your system:
which -a python
To get the version for python 3 (which is what you should be on):
python3 --version
To get the version for pip:
pip -v
For windows:
python3 --version
pip -v
If the versions are incorrect then you can either install the right version of pip in your env or change python paths. First option is recommended.
If you are using macOS. Entering the command which -a python will show a very old Python 2.X version. Do not tamper with this or it's path as it is needed by macOS to run.

Troubleshooting: Kernel always dies using IJulia in IPython notebook

I recently began using julia, and I would like to use in with IPython Notebook/Jupyter.
So, I installed julia using MacPorts, i.e. sudo port install julia. Following the installation instructions here: https://github.com/JuliaLang/IJulia.jl
After the prompt, I used "Pkg.add("IJulia") to install IJulia.
However, I cannot use Julia with IPython notebook. After opening the notebook with
ipython notebook --profile=julia
the kernel for the julia notebook dies instantly and cannot be restarted.
The error on the Terminal shows:
[I 19:03:19.410 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel dc00ae3a-8fa6-4d01-a802-f7845a16a9ba restarted
ERROR: SHA256 not defined
in include at /opt/local/lib/julia/sys.dylib
in process_options at /opt/local/lib/julia/sys.dylib
in _start at /opt/local/lib/julia/sys.dylib
while loading /Users/NAME/.julia/v0.3/IJulia/src/kernel.jl, in expression starting on line 6
I suspect I have installed IJulia incorrectly? How can I solve this?
(The version of julia is julia version 0.3.11. The version of python is Python 2.7.10. The version of ipython is 4.0.0.)
The current stable version of Julia is v0.4.0.
You should download it directly from the Julia homepage (.dmg):
http://julialang.org/downloads/
Having done that, run it and do Pkg.add("IJulia") again.
Then from within Julia do
using IJulia
notebook()
Note that the Jupyter Notebook (the new name for what used to be the IPython Notebook) is run as
jupyter notebook
The --profile julia is no longer necessary and should be removed.
Furthermore, this (jupyter notebook) will only work if you had a previous installation of Jupyter, which seems to be the case. In this case, I suggest you upgrade it with conda, if you installed Anaconda, or with pip.)

On SageMath Cloud, how can I use Python 3 notebooks?

I'm using the fantastic SageMath Cloud service to remotely collaborate with a partner. In particular, I'm using IPython notebooks. Unfortunately, the language seems to default to Python 2; I would prefer Python 3.
SSH'ing into my project, I can see that IPython 3 is actually installed. Is there a way to coerce SMC into using Python 3 for notebooks?
I have tried the instructions mentioned in the FAQ, i.e.,
ln -s /usr/bin/python3 ~/bin/python
ln -s /usr/bin/ipython3 ~/bin/ipython
While this works for invoking Python from the SSH commandline, it doesn't seem to affect the kernel used by IPython notebooks created from the web GUI.
Once you open an IPython Notebook on SageMathCloud you can switch the kernel to a variety of choices, including Python 3. To do that, use the 'Kernel' menu, then 'Change kernel', then 'Python 3'.
Switching to the Python 3 kernel in the IPython Notebook on SageMathCloud is discussed in this discussion the sage-cloud mailing list.
Is this what your question is about, or are you asking how to make that choice the default when you open a new IPython Notebook on SageMathCloud?
To get the fastest answers to SageMathCloud questions, use the sage-cloud mailing list.

IPython notebook kernel dies on import

I am running IPython Notebook on Enthought's Canopy 64 bit distribution, Ubuntu 14.04.
I've tried install libtiff, but when I import it in IPython Notebook, the kernel always dies at the import statement. What could possibly be causing this? Canopy is my default Python distribution, my paths all seem like they're set up appropriately, although I'm convinced that something in my Python setup is borked.
Any advice is appreciated.
EDIT: I'll be more specific. Output of sys.path:
['',
'/home/joe/Enthought/Canopy_64bit/User/src/svn',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python27.zip',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/plat-linux2',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/lib-tk',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/lib-old',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/lib-dynload',
'/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages',
'/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/PIL',
'/home/joe/opencv-2.4.9',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/site-packages',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/site-packages/IPython/extensions']
As for how to install Python packages, I assume I go to ~/Enthought/Canopy_64bit/User/lib/python2.7/site-packages and run pip, setup.py, or a shell script, per the specific package's instructions. Is that correct? The article that I linked has the following line: "To install a package which is not available in the Canopy / EPD repository, follow standard Python installation procedures from the OS command line.", which seems to imply that I install per package instructions.
In .bashrc, I have the following:
VIRTUAL_ENV_DISABLE_PROMPT=1 source /home/joe/Enthought/Canopy_64bit/User/bin/activate
export PYTHONHOME=/home/joe/Enthought/Canopy_64bit/User/bin
export PATH=/home/joe/Enthought/Canopy_64bit/User/bin
export PYTHONPATH=/home/joe/Enthought/Canopy_64bit/User/bin
From what I understand of the linked articles, this means I'm setting Canopy User as my default Python distribution. I'm sure I'm doing something a bit over my head here, but I can't understand what else I need to do to fix this issue.
Worse yet, now I'm getting an "ImportError: No module named site" with these .bashrc settings, when trying to start IPython notebook or python from the command line. I can run only from the Canopy GUI.
Closing this. I made it harder than necessary.
It turns out, the PYTHONHOME and PYTHONPATH .bashrc variables were causing some conflicts. Commenting them out seems to have resolved the issue.
Installing outside packages does, indeed, happen from the home (~) directory.

Using ipython nbconvert with Enthought Canopy

I am using Enthought/Canopy (version 1.1.0.1371) and would like to use nbconvert to convert ipython notebooks to other formats. nbconvert has now been incorporated into ipython and is not available outside of ipython. However, it is apparently not available within the Canopy distribution. Any suggestions?
I believe it is available in the current version of canopy.
You can always install canopy package the old fashioned way with setup.py, just make sure you call Canopy's python. That way, you don't have to always wait for the package manager to incorporate changes to repos.
If canopy's python is your system python, merely python setup.py install should work. If you have multiple python paths, find Canopy's python; on my Ubuntu system it's:
~/Enthought/Canopy_64bit/User/bin/python
So I would just do:
~/Enthought/Canopy_64bit/User/bin/python setup.py install
1) Use the Canopy Package manager to update IPython to version 1.0
2) Open a Canopy User Python shell / terminal / command prompt. If you did not make Canopy your default Python, be sure to see this article: https://support.enthought.com/entries/23646538-Make-Canopy-User-Python-be-your-default-Python
3) ipython nbconvert ....
4) http://knowyourmeme.com/memes/profit