Issue exiting code

Hello folks!

I am running a python code with tensorflow (installed with pip install tensorflow-gpu, nvidia drivers and cuda are compatible and work, Ubuntu 16.04) and at the end of the execution I run into the following problem:

 

Traceback (most recent call last):
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/pydevconsole.py", line 221, in do_exit
import java.lang.System
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'java'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/dalsasso/sarcnn/main.py", line 96, in <module>
tf.app.run()
File "/home/dalsasso/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))

 

Note that the program runs fine, it just isn't ending properly and I have to press the stop button to end the the program.

Please note that when running the same code from a terminal with the same setup as the venv used in pycharm I don't experience any problem and it works just fine.

1
1 comment

Hi Emanuele,

I had the same problem.  The cause was calling sys.exit(main()) from my code, but not returning an exit value from the main method.  Once I put in a return code, the exception listed, which was quite similar to yours, disappeared.

I hope this helps.

Chris

 

1

Please sign in to leave a comment.