[Thread Prev][Thread Next][Index]

Re: [ferret_users] Pyferret, jupyter notebook and ferretmagic





Le 5 sept. 2018 à 21:48, Karl Smith - NOAA Affiliate <karl.smith@xxxxxxxx> a écrit :

Hi Olivier,

Just to follow up on this.  I assume that using PyFerret built for your system (either through an Anaconda or a Homebrew build) has fixed the issues with finding the libraries from a previous discussion thread.

For PyFerret Python users using Jupyter notebooks:  

Jupyter notebooks started from JupyterHub do not normally have user's environment variables (such as those set in $HOME/.bashrc) for Python sessions.  If the PyFerret environment variables are not assigned in your Jupyter notebook, one can use the pyferret.addenv method with just the arguments FER_DIR= (path to pyferret installation directory) and FER_DAT= (path to datasets directory) to assign the default values.  There is also a pyferret.addpath method that adds to the environment variables just like the Faddpath command.  

However, the pyferret module needs to be found in order to use these pyferret methods.  If the pyferret module is not found when importing, then its location needs to be added to sys.path.  So something like the following, where ferdir is the (string) location of the PyFerret installation and ferdat is the (string) location of the datasets directory:
    import sys 
    sys.path.insert(1, '%s/lib/python%d.%d/site-packages' % (ferdir, sys.version_info[0], sys.version_info[1]))
    import pyferret
    pyferret.addenv(FER_DIR=ferdir, FER_DAT=ferdat)
    pyferret.start(journal=False, quiet=True, unmapped=True) 

Best regards,
Karl

Karl,

Thanks for the help. It works now, great !

By the way : should it be FER_DAT or FER_DATA ?

Olivier

-- 
Dr. Olivier Marti  - mailto:olivier.marti@xxxxxxxxxxxx
Laboratoire des Sciences du Climat et de l'Environnement
Institut Pierre Simon Laplace
Laboratoire CEA-CNRS-UVSQ  -  UMR 8212
Tel : +33 1 69 08 77 27 - Mob : +33 6 45 36 43 74
Fax : +33 1 69 08 30 73




[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement