0 votes
131 views
Hi Data Lab!

Used to work fine but now basic functionality no longer works. I reloaded my computer and something must have updated. Please help! It seems somebody else asked this question but it was resolved over email.

Thanks,

Lilly
by lsandmeier (140 points) | 131 views

1 Answer

0 votes

Hi Lilly,

Our Jupyter notebook server was recently updated and the behavior of the '!' escape in notebook cells has changed in the newer version.  Instead we are recommending people use the '%%bash' magic until we can find a way to restore the '!' escape.  For example,

    %%bash
    pip install sparclclient

Note that in this particular case the 'sparclclient' package is already installed as part of the base notebook environment.

Hope this helps, please post back if you still have problems.

by datalab (21.6k points)
Hello!
Thank you for your help!
Unfortunately after trying %%bash pip I received an error:
UsageError: Line magic function '%%bash' not found, along with a ton of error messages.
Is there something I should try next?
Lilly Sandmeier
I am realizing some context may help. The reason that I was trying to use pip install was so that I could get the code below to run, which was working a few days ago but then stopped and began giving me error messages to install 'requests' and 'aiohttp'. It is no longer giving those error messages, but is now just running forever. It may work better to tackle this issue instead, rather than the install. Not sure, but appreciate all the help we can get!
Thanks,
Lillly

Heres the code that was working, then giving errors, and now runs forever:

uri = "https://data.desi.lbl.gov/public/edr/vac/edr/fastspecfit/fuji/v3.2/catalogs/fastspec-fuji.fits"

from astropy.io import fits

# `fits.open` will download the primary header
with fits.open(uri, use_fsspec=True) as hdul:  

    # Download a single header
    header = hdul[1].header
    header = hdul[2].header
    # Download a single data array
    data = hdul[1].data
    moredata = hdul[2].data
Hi Lilly,

the missing packages are now installed. However, on the large file you are downloading in your code, astropy is timing out internally. We suggest you download the file separately, and then open it locally, like this:

##############
from astropy.io import fits
import wget

# download (one-time; takes about 10 minutes)
fname = 'fastspec-fuji.fits'
uri = 'https://data.desi.lbl.gov/public/edr/vac/edr/fastspecfit/fuji/v3.2/catalogs/'
wget.download(uri+fname,out=fname)

# local file access
with fits.open(fname, use_fsspec=True) as hdul:  

    # Download a single header
    header = hdul[1].header
    ...
##############

Let us know if you encounter more troubles.
Hello!
That worked great, thank you so much for all of your help!
Thanks,
Lilly

447 questions

463 answers

473 comments

658 users

Welcome to Data Lab Help Desk, where you can ask questions and receive answers from other members of the community.

Categories