kylebarron / stata_kernel

A Jupyter kernel for Stata. Works with Windows, macOS, and Linux.
https://kylebarron.dev/stata_kernel/
GNU General Public License v3.0
264 stars 57 forks source link

Loading shared library error, libpng, Stata, Hydrogen #331

Open mateokhan opened 4 years ago

mateokhan commented 4 years ago

When using Hydrogen in Atom, I don't see the expected output when using Stata code; instead, I receive an error, the error in the log:

/usr/local/stata15/stata-se: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

I originally had difficulty getting Stata to work on Linux Mint 19.3. Used a workaround utilizing https://github.com/dirtyhawk/stata-integration.git ; due to there being a difficulty getting that libpng12 to come in. The workaround created a folder named: /usr/local/stata15/libpngworkaround/lib

This is where the libpng12.so.0 is, is there a simple way of directing to it? Or might I need to retry the Stata install and figure out how to avoid the workaround? My bad if I'm way off here.

kylebarron commented 4 years ago

Are you able to run Stata outside Atom? If so, then you probably just need to open Atom with your LD_LIBRARY_PATH set to include that library location. Something like

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/path/to/libraries" atom /path/to/code/dir

Then I think Atom will be opened with that LD_LIBRARY_PATH in its process.env, and that will be passed on to the kernel when it's created.

Also, I haven't used Stata for a while, but you should check out my previous solution for getting it to work with libpng on linux: https://github.com/kylebarron/stata-png-fix

mateokhan commented 4 years ago

I am able to run Stata outside of Atom. I did try and set the LD_LIBRARY_PATH, and looked at the link you provided for https://github.com/kylebarron/stata-png-fix to see if that might improve anything. Still receiving the same error after.

Just to make sure I'm not introducing operator error: I used LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/Stata15"

Just to make sure, I did see that hydrogen works with other kernels (python), and the problem was reproducible using JupyterLab (i.e. same error for Stata, works with python).

kylebarron commented 4 years ago

Oh the issue there is that you're providing the path to the wrong place. You need to find wherever libpng is, not where the stata executable is

mateokhan commented 4 years ago

Alright! Got it pointed to the right location, I assume, but now getting a very different error. The console_debug is now just my Stata welcome screen.

[?1h= _ (R) / / __/ / ___/ / / // / // 15.1 Copyright 1985-2017 StataCorp LLC Statistics/Data Analysis StataCorp 4905 Lakeway Drive Special Edition College Station, Texas 77845 USA 800-STATA-PC http://www.stata.com 979-696-4600 stata@stata.com 979-696-4601 (fax)

Single-user Stata perpetual license: Serial number: #### Licensed to: X X

Notes:

  1. Unicode is supported; see help unicode_advice.
  2. Maximum number of variables is set to 5000; see help set_maxvar.

running /usr/local/bin/profile.do ...

.

If this is a different "issue" I can close this and continue to try and make it work. The LD path just needed the command to be pointed in the right direction.

kylebarron commented 4 years ago

What's the error? That looks normal on the console debug script

mateokhan commented 4 years ago

When I attempt to run a line in hydrogen, I get a very long red error pane in hydrogen with Stata as the header, that has a lot of TIMEOUT errors (this looked similar to before when I wasn't locating libpng library), but at the end it's confusing. The last line states,

<pexpect.pty_spawn.spawn object at 0x7f5d10440ac8> command: /usr/local/stata15/stata-se args: [b'/usr/local/stata15/stata-se'] buffer (last 100 chars): 'riables is set to 5000; see help set_maxvar.\r\n\r\nrunning /usr/local/bin/profile.do ...\r\n\r\n\x1b[0m\x1b[37m. ' before (last 100 chars): 'riables is set to 5000; see help set_maxvar.\r\n\r\nrunning /usr/local/bin/profile.do ...\r\n\r\n\x1b[0m\x1b[37m. ' after: match: None match_index: None exitstatus: None flag_eof: False pid: 2237 child_fd: 80 closed: False timeout: 30 delimiter: logfile: <_io.TextIOWrapper name='/home/user/.stata_kernel_cache/console_debug.log' mode='w' encoding='utf-8'> logfile_read: None logfile_send: None maxread: 2000 ignorecase: False searchwindowsize: None delaybeforesend: None delayafterclose: 0.1 delayafterterminate: 0.1 searcher: searcher_re: 0: re.compile('\r\n. ')

When I try to run this with Jupyter console in terminal, there's quite a bit more error lines that look similar, but the very end says File "/home/user/anaconda3/lib/python3.7/site-packages/jupyter_console/ptshell.py", line 326, in init_kernel_info raise RuntimeError("Kernel didn't respond to kernel_info_request") RuntimeError: Kernel didn't respond to kernel_info_request

I don't know if this latter information helps, just trying to give a full picture.