question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"No such file or directory" when creating Jupyter notebook from scratch

See original GitHub issue

I’m running into a problem with a notebook I’ve created from scratch in Jupyter that I’m not getting with a with the included example hyperas/examples/simple_notebook.ipynb.

It appears that hyperas is looking for a temperary file that does not exist.

Any thoughts about what is going wrong?

Steps to recreate the error:

  1. Create new Jupyter notebook
  2. Copy the sample code from the hyperas README and pasted it into the notebook created in 1)
  3. Selected “Cell->Run All”
  4. Error is thrown: See below
  5. Selected “Kernel -> Restart and Run All”
  6. Error is thrown: same as 4)
  7. “File -> Save and Checkpoint”, “Kernel -> Restart and Run All”
  8. Error is thrown: same as 4) and 6)
Using TensorFlow backend.
/usr/local/lib/python2.7/dist-packages/hyperas/optim.py
/usr/local/lib/python2.7/dist-packages/hyperas/optim.py
/usr/local/lib/python2.7/dist-packages/hyperas/optim.py
<ipython-input-1-43ea71f3309d>
/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py
/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py
/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py
/usr/local/lib/python2.7/dist-packages/ipykernel/zmqshell.py
/usr/local/lib/python2.7/dist-packages/ipykernel/ipkernel.py
/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py
/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py
/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py
/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py
/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py
/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py
/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py
/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py
/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py
/usr/local/lib/python2.7/dist-packages/zmq/eventloop/ioloop.py
/usr/local/lib/python2.7/dist-packages/ipykernel/kernelapp.py
/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py
/usr/local/lib/python2.7/dist-packages/ipykernel_launcher.py
/usr/lib/python2.7/runpy.py
/usr/lib/python2.7/runpy.py
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-1-43ea71f3309d> in <module>()
     80                                           algo=tpe.suggest,
     81                                           max_evals=5,
---> 82                                           trials=Trials())
     83     X_train, Y_train, X_test, Y_test = data()
     84     print("Evalutation of best performing model:")

/usr/local/lib/python2.7/dist-packages/hyperas/optim.pyc in minimize(model, data, algo, max_evals, trials, rseed, notebook_name, verbose)
     40     best_run = base_minimizer(model=model, data=data, algo=algo, max_evals=max_evals,
     41                               trials=trials, rseed=rseed, full_model_string=None,
---> 42                               notebook_name=notebook_name, verbose=verbose)
     43 
     44     best_model = None

/usr/local/lib/python2.7/dist-packages/hyperas/optim.pyc in base_minimizer(model, data, algo, max_evals, trials, rseed, full_model_string, notebook_name, verbose, stack)
     60         model_str = full_model_string
     61     else:
---> 62         model_str = get_hyperopt_model_string(model, data, notebook_name, verbose, stack)
     63     temp_file = './temp_model.py'
     64     write_temp_files(model_str, temp_file)

/usr/local/lib/python2.7/dist-packages/hyperas/optim.pyc in get_hyperopt_model_string(model, data, notebook_name, verbose, stack)
    126             print(i[1])
    127         calling_script_file = os.path.abspath(inspect.stack()[stack][1])
--> 128         with open(calling_script_file, 'r') as f:
    129             source = f.read()
    130 

IOError: [Errno 2] No such file or directory: '/work/models/regression/Keras-Nonlinear-Regression/<ipython-input-1-43ea71f3309d>'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

31reactions
yakouyangcommented, May 4, 2017

If you run your code in jupyter, function “optim.minimize” must contain a parameter “notebook_name”. As the example “simple_notebook.ipynb”:

best_run, best_model = optim.minimize(model=model,
                                      data=data,
                                      algo=tpe.suggest,
                                      max_evals=5,
                                      trials=Trials(),
                                      notebook_name='simple_notebook')
8reactions
mahacodercommented, Jun 12, 2018

This fix does not work in Google colab. Has anybody figured out how to run it in colab yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when executing `jupyter notebook` (No such file or ...
It seems to me as though the installation has messed up somehow. Try running: # For Python 2 pip install --upgrade --force-reinstall ...
Read more >
[Errno 2] No such file or directory - Jupyter Community Forum
I've tried creating a shared folder for both the notebook and the CSV but the notebook still can't find the CSV file.
Read more >
Opening files and reading from files
Here is likely the most common error you'll get when trying to open a file. FileNotFoundError: [Errno 2] No such file or directory:...
Read more >
What to do when things go wrong - The Jupyter Notebook
If you're using a menu shortcut or Anaconda launcher to start it, try opening a terminal or command prompt and running the command...
Read more >
FileNotFoundError: No such file or directory. This error occurs ...
I don't think you can easily change the path to your desktop since IBMQ's jupyter notebook is running on IBM's server, not your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found