jupyter setup i18n on exiting notebook - ipython

I have been trying to translate jupyter notebook interface with my native language, using existing i18n implementation. I have already created translation files just like readme advised and now i want to add it to jupyter.
https://github.com/jupyter/notebook/tree/master/notebook/i18n
but i can't find /notebook/i18n/ folder on my computer ( Ubuntu 16.04 ).Do i have to install jupyter one more time or can i just add translate files to already existing jupyter installation on my machine and run it?

I just reinstalled jupyter and this time i18n folder is on its place in:
/usr/local/lib/python3.5/dist-packages/notebook/i18n/i18n

First, find lib_path by python:
import sys
from distutils.sysconfig import get_python_lib
print (get_python_lib())
And you will find it in
${lib_path}/notebook/i18n/

Related

Missing Jupyter Notebook Kernels in VSCode

I have multiple people working on the same AWS EMR cluster to run some Spark jobs. This is being done through Jupyter Notebooks which are created/modified using the Jupyter extension installed on a SSH Target through vscode. The modules are installed on the base conda environment that is included with the /emr/notebook-env/. Some people can see the correct kernel that is associated with the base conda environment in their vscode window when working on notebooks. However, some don't see this kernel as an option. How do I make sure that everyone's vscode lists the appropriate kernel when they are creating new notebooks or modifying existing notebooks?
Another potential reason this could happen is that the Jupyter exentsion of VSCode is not installed.
To add the Jupyter extension for VSCode, search for it by clicking extensions icon in lefthand toolbar, then searching for Jupyter and installing.
The user having the issue had to update their vscode and that fixed the issue

simpleitk installation in anaconda

i installed simpleitk in anaconda using command
conda install -c simpleitk simpleitk then followed link https://github.com/SimpleITK/SimpleITKCondaRecipe to build it but it's not connecting to itk.org to build.
import SimpleITK as sitk on jupyter notebook is working but sitk.show() is not working. moreover when i tried to follow the commands from http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/00_Setup.html,
from downloaddata import fetch_data, fetch_data_all not working.
even the command fetch_data_all(os.path.join('..','Data'), os.path.join('..','Data','manifest.json')) is not working. i am very new to simpleitk and don't know whether it is due to build not processed. please tell me how to solve my problems. i have been trying from many days, pl help me. moreover how to make imagej as default for simpleitk. i know lots of questions but i would be greatful if solved.
You seem to be having multiple problems, all of which have to do with installing a working environment and less specific to SimpleITK.
You installed SimpleITK using the conda install command, so there was no need to build it using the conda build command. Check that you have it installed correctly and see which version you have:
import SimpleITK as sitk
print(sitk.Version())
The functions fetch_data and fetch_data_all are part of a module found in the SimpleITK notebooks repository. To use the code from that repository you will need to clone it using git:
git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks.git
Then you can run the notebooks or copy the relevant modules to your directory and work with them there.
The sitk.Show() command assumes that you have the ImageJ/Fiji program installed which is likely why it is not working (I am guessing here as you did not provide sufficient detail).

Can't launch PySpark in browser (windows 10)

I'm trying to launch PySpark notebook in my browser by typing in pyspark from the console, but I get the following error:
c:\Spark\bin>pyspark
python: can't open file 'notebook': [Errno 2] No such file or directory
What am I doing wrong here?
Please help?
Sounds like the jupyter notebook is either not installed or not in your path.
I prefer to use Anaconda for my python distribution and Jupyter comes standard and will install all necessary path information as well.
After that as long as you have set PYSPARK_PYTHON_DRIVER=jupyter and PYSPARK_PYTHON_DRIVER_OPTS='notebook' correctly you are good to go.
You want to launch the jupyter notebook when you invoke the command pyspark. Therefore you need to add the following to the bash_profile or zshrc_profile.
export PYSPARK_SUBMIT_ARGS="pyspark-shell"
export PYSPARK_DRIVER_PYTHON=ipython
export PYSPARK_DRIVER_PYTHON_OPTS="notebook" pyspark

how to access pyspark from jupyter notebook

I have been using pyspark [ with python 2.7] in an ipython notebook on Ubuntu 14.04 quite successfully by creating a special profile for spark and starting the notebook by calling $ipython notebook --profile spark. The mechanism for creating the spark profile is given on many websites but i have used the one given in here.
and the $HOME/.ipython/profile_spark/startup/00-pyspark-setup.py contains the following code
import os
import sys
# Configure the environment
if 'SPARK_HOME' not in os.environ:
os.environ['SPARK_HOME'] = '/home/osboxes/spark16'
# Create a variable for our root path
SPARK_HOME = os.environ['SPARK_HOME']
# Add the PySpark/py4j to the Python Path
sys.path.insert(0, os.path.join(SPARK_HOME, "python", "build"))
sys.path.insert(0, os.path.join(SPARK_HOME, "python"))
I have just created a new VM of Ubuntu 16.04 for my students where I want them to run pyspark programs in ipython notebook. Python, Pyspark is working quite well. We are using Spark 1.6.
However I have discovered that the current versions of ipython notebook [ or jupyter notebook ] whether downloaded through Anaconda or installed with sudo pip install ipython .. DO NOT SUPPORT the --profile option and all configuration parameters have to be specified in the ~/.jupyter/jupyter_notebook_config.py file.
Can someone please help me with the config parameters that I need to put into this file? Or is there an alternative solution? I have tried the findshark() explained here but could not make it work. Findspark got installed but findspark.init() failed, possibly because it was written for python 3.
My challenge is that everything is working just fine on my old installation of ipython on my machine but my students who are installing everything from scratch cannot get pyspark going on their VMs.
i work with spark just for test purpose locally from ~/apps/spark-1.6.2-bin-hadoop2.6/bin/pyspark
PYSPARK_DRIVER_PYTHON=jupyter PYSPARK_DRIVER_PYTHON_OPTS="notebook" ~/apps/spark-1.6.2-bin-hadoop2.6/bin/pyspark
I have found a ridiculously simple answer to my own question by looking at the advice given in this page.
forget about all configuration files etc. Simply start notebook with this command -- $IPYTHON_OPTS="notebook" pyspark
thats all.
Obviously the paths to SPARK have to set as given here.
and if you get an error with Py4j then look at this page.
With this you are good to go. The spark context is available at sc so don't import it again
With Python 2.7.13 from Anaconda 4.3.0 and Spark 2.1.0 on Ubuntu 16.04:
$ cd
$ gedit .bashrc
Add following lines (where "*****" is the proper path):
export SPARK_HOME=*****/spark-2.1.0-bin-hadoop2.7
export PATH=$SPARK_HOME/bin:$PATH
export PATH=$SPARK_HOME/sbin:$PATH
export PYTHONPATH=$SPARK_HOME/python/:$PYTHONPATH
export PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.10.4-src.zip:$PYTHONPATH
Save, then do:
$ *****/anaconda2/bin/.pip install py4j
$ cd
$ source .bashrc
Check if it works with:
$ ipython
In [1]: import pyspark
For more details go here

Problems with importing self-defined module in Jupyter notebook using PyCharm

I'm trying to import a self-defined module in a Jupyter notebook using PyCharm (2016.1). However, I always get "ImportError: No module named xxx". Importing packages like NumPy or Matplotlib works fine. The self-defined module and the notebook are in the same directory and I've tried to set the directory as sources root. How can I fix this? Thanks a lot!
If you run the following in your notebook...
import sys
sys.path
...and you don't see the path to the directory containing the packages/modules, there are a couple ways around it. I can't speculate why this might happen in this example. I have seen some discrepancies in the results of sys.path when running Jupyter locally from PyCharm on OS X vs. on a managed Linux service.
An easy if hacky workaround is to set the sys path in your notebook to reflect where the packages/modules are rooted. For example, if your notebook was in a subdirectory from where the packages or modules are and sys.path only reflects that subdirectory:
import sys
sys.path.append("../")
The point is that sys.path must include the the directory the packages and modules are rooted in so the path you append will depend on the circumstances.
Perhaps a more proper solution, if you are using a virtualenv as your project interpreter, is to create a setup.py for your project and install the project as an editable package with pip. E.g. pip install -e . Then as long as Jupyter is running from that virtualenv there shouldn't be any issues with imports.
One ugly gotcha I ran into on OS X was Jupyter referencing the wrong virtualenv when started. This should also be apparent by inspecting the results of sys.path. I don't really know how I unintentionally managed set this but presume it was due to futzing around my first time getting Jupyter working in PyCharm. Instead of starting Jupyter with the local virtual env it would run with the one defined in ~/Library/Jupyter/kernels/.python/kernel.json. I was able to clear it by cleaning out that directory, e.g. rm -r ~/Library/Jupyter/kernels/.python.
As stated by Thomas in the comments make sure that your notebook serving path and project path are same. When you start your notebook in pycharm you should get something like this :
Serving notebooks from local directory: <path to your project root folder>