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.

OSError while executing sample code

See original GitHub issue

The sample code given on hyperas homepage ends up in the following error stack trace:

OSError                                   Traceback (most recent call last)
<ipython-input-15-871ae3941e46> in <module>()
     76                                           algo=tpe.suggest,
     77                                           max_evals=5,
---> 78                                           trials=Trials())
     79     X_train, Y_train, X_test, Y_test = data()
     80     print("Evalutation of best performing model:")

G:\Programs\anaconda3\envs\py35\lib\site-packages\hyperas\optim.py in minimize(model, data, algo, max_evals, trials, functions, rseed, notebook_name, verbose, eval_space, return_space)
     65                                      full_model_string=None,
     66                                      notebook_name=notebook_name,
---> 67                                      verbose=verbose)
     68 
     69     best_model = None

G:\Programs\anaconda3\envs\py35\lib\site-packages\hyperas\optim.py in base_minimizer(model, data, functions, algo, max_evals, trials, rseed, full_model_string, notebook_name, verbose, stack)
     94         model_str = full_model_string
     95     else:
---> 96         model_str = get_hyperopt_model_string(model, data, functions, notebook_name, verbose, stack)
     97     temp_file = './temp_model.py'
     98     write_temp_files(model_str, temp_file)

G:\Programs\anaconda3\envs\py35\lib\site-packages\hyperas\optim.py in get_hyperopt_model_string(model, data, functions, notebook_name, verbose, stack)
    176     else:
    177         calling_script_file = os.path.abspath(inspect.stack()[stack][1])
--> 178         with open(calling_script_file, 'r') as f:
    179             source = f.read()
    180 

OSError: [Errno 22] Invalid argument: 'path\\to\\working\\directory\\<ipython-input-15-871ae3941e46>'

I am now able to understand the cause of the error. I am using Python 3.5.3 (Anaconda virtual environment) on Windows 10. Please help me resolve it. If I am creating a redundant issue, I apologise for the same.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
maxpumperlacommented, Jan 24, 2018

@daas-ankur-shukla it seems you’re using hyperas from within ipython. that doesn’t work, unfortunately. just save your code in a .py file and run it with python from command line.

2reactions
maxpumperlacommented, Jan 26, 2018

can you run the example I linked you to? If so, ask how your example differs from that. not me. yourself

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling OSError exception in Python - GeeksforGeeks
OSError is a built-in exception in Python and serves as the error class for the os module, which is raised when an os...
Read more >
OSError: [Errno 8] Exec format error - Stack Overflow
OSError: [Errno 8] Exec format error can happen if there is no shebang line at the top of the shell script ... To...
Read more >
What is the os.error in Python? - Educative.io
The os.error in Python is the error class for all I/O errors and is an alias of the OSError exception. All the methods...
Read more >
Python OSError - Linux Hint
Here's an example of an OSError. You can see the 'os' module, which is necessary for many Python programs that work with files...
Read more >
tf.function raises OSError "could not get source code ... - GitHub
tf.function raises an OSError exception with the message "could not get source code" when I run it in a Python shell.
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