stata_kernel icon indicating copy to clipboard operation
stata_kernel copied to clipboard

Install not working

Open po4dun opened this issue 4 years ago • 14 comments

Hi! I would love to use Stata with Jupyter! However on 2 of my machines and on a colleague's as well, I run into problems installing the kernel. It seems similiar to #276 , but I can't solve it with the point raised there

I did a fresh Anaconda install, link the automation library, follow your guide on the website:

pip install stata_kernel

works as expected but after

python -m stata_kernel.install

I always end up with the same problem on multiple PCs. There is no logfile created in .stata_kernel_cache/ and .stata_kernel.conf is not yet created. please check out my console's output. Thanks so much!

C:\Users\franzeckf>python -m stata_kernel.install
Traceback (most recent call last):
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 184, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stata_kernel\__init__.py", line 5, in <module>
    from .kernel import StataKernel
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stata_kernel\kernel.py", line 16, in <module>
    from .config import config
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stata_kernel\config.py", line 150, in <module>
    config = Config()
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stata_kernel\config.py", line 65, in __init__
    self.raise_config_error('stata_path')
  File "C:\Users\franzeckf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stata_kernel\config.py", line 140, in raise_config_error
    raise ValueError(dedent(msg))
ValueError: stata_path option in configuration file is missing or invalid
Refer to the documentation to see how to set it manually:

https://kylebarron.dev/stata_kernel/using_stata_kernel/configuration/

  • Win 10
  • Stata version 15
  • Package version 1.11.2

po4dun avatar Mar 22 '20 17:03 po4dun

Hi everyone

I am also trying to install 'stata_kernel' and I am facing a problem similar to that of @po4dun. When I type

pip install stata_kernel

on the Anaconda prompt, it runs smoothly, but when I try to run

python -m stata_kernel.install

I get the problem with 'stata_path'. Could you help me?

Obs: The main difference is that I am using Stata 16 and I am trying to install directly from the Anaconda prompt, because I couldn't manage to install the package using the cmd.

This is the output:

C:\Users\Otavio>python -m stata_kernel.install Traceback (most recent call last): File "C:\Users\Otavio\Anaconda3\lib\runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "C:\Users\Otavio\Anaconda3\lib\runpy.py", line 109, in get_module_details import(pkg_name) File "C:\Users\Otavio\Anaconda3\lib\site-packages\stata_kernel_init.py", line 5, in from .kernel import StataKernel File "C:\Users\Otavio\Anaconda3\lib\site-packages\stata_kernel\kernel.py", line 16, in from .config import config File "C:\Users\Otavio\Anaconda3\lib\site-packages\stata_kernel\config.py", line 150, in config = Config() File "C:\Users\Otavio\Anaconda3\lib\site-packages\stata_kernel\config.py", line 65, in init self.raise_config_error('stata_path') File "C:\Users\Otavio\Anaconda3\lib\site-packages\stata_kernel\config.py", line 140, in raise_config_error raise ValueError(dedent(msg)) ValueError: stata_path option in configuration file is missing or invalid Refer to the documentation to see how to set it manually:

https://kylebarron.dev/stata_kernel/using_stata_kernel/configuration/

Windows 10 Stata version 16.0 Package version 1.11.2 Python 3.7.3

otavio-canozzi avatar Mar 22 '20 19:03 otavio-canozzi

same problem here. although on a mac with Stata 15

CarolineMorton avatar Mar 23 '20 14:03 CarolineMorton

Can you try

pip uninstall stata_kernel
pip install stata_kernel==1.10.5
python -m stata_kernel.install

kylebarron avatar Mar 23 '20 19:03 kylebarron

Hi Kyle,

I'm still getting the same error:

Installing Jupyter kernel spec WARNING: Could not find Stata path. Refer to the documentation to see how to set it manually: https://kylebarron.github.io/stata_kernel/using_stata_kernel/configuration

Do you have an example for the config file?

I think it may not work with StataIC - is that correct? Only SE or MP

CarolineMorton avatar Mar 23 '20 20:03 CarolineMorton

Hi Kyle,

Thanks for your reply.

Now, after running what you suggested, I get the same error of @CarolineMorton.

otavio-canozzi avatar Mar 23 '20 20:03 otavio-canozzi

Can you try

pip uninstall stata_kernel
pip install stata_kernel==1.10.5
python -m stata_kernel.install

This worked for me! After pip install stata_kernel I just edited the now exisiting .stata_kernel.conf: —>writing the correct path to: stata_path

po4dun avatar Mar 23 '20 23:03 po4dun

@CarolineMorton I forgot that there's a caveat to using Stata IC on MacOS. StataCorp doesn't ship with the console version on MacOS, so you have to use the automation execution mode instead. See if the docs here are helpful: https://kylebarron.dev/stata_kernel/using_stata_kernel/configuration/#execution_mode

kylebarron avatar Apr 02 '20 17:04 kylebarron

I've run into a similar problem. There seem to be two ways around it

  1. If you create a a ~/.stata_kernel.conf prior to running python -m stata_kernel.install that contains
[stata_kernel]
stata_path = <PATH>

it should fix it. I am not sure if this will prevent the install from writing any useful defaults to that file during install or not.

  1. You can also take advantage of creating a global stata_kernel.conf at /etc/stata_kernel.conf. However, I've encountered a bug when using the global feature during install because this line of code still requires that you at least create an empty `~/.stata_kernel.conf

jeffmax avatar Apr 22 '20 15:04 jeffmax

@jeffmax if you're interested in making a pull request to fix an issue, you're welcome to

kylebarron avatar Apr 22 '20 15:04 kylebarron

Thanks @kylebarron I will see what I can figure out.

jeffmax avatar Apr 23 '20 21:04 jeffmax

Dear Kyle,

I've been having similar issues as others in getting Stata code to run inline in Atom. The error message I get when I try to run something is exactly the same as #276. I have tried the fixes listed there as well as the recommendation to uninstall the kernel and reinstall an earlier version discussed in this thread. Still not working. I am running StataIC 16.1 on Windows 10. Is there something else I can try? Note that I don't have any issues with the R kernel and getting R code to run in case that helps to narrow it down. Thanks!

eteitelbaum avatar May 27 '20 19:05 eteitelbaum

Dear Kyle,

I've been having similar issues as others in getting Stata code to run inline in Atom. The error message I get when I try to run something is exactly the same as #276. I have tried the fixes listed there as well as the recommendation to uninstall the kernel and reinstall an earlier version discussed in this thread. Still not working. I am running StataIC 16.1 on Windows 10. Is there something else I can try? Note that I don't have any issues with the R kernel and getting R code to run in case that helps to narrow it down. Thanks!

P.S. I was able to get it to work by opening Atom from the Anaconda Prompt,

eteitelbaum avatar Jun 01 '20 04:06 eteitelbaum

P.S. I was able to get it to work by opening Atom from the Anaconda Prompt,

Good find. When you open Atom from a terminal, it inherits the environment variables of the terminal. I don't use Windows, but I think that when you install Python through Anaconda on Windows, you can essentially only access Python through the Anaconda Prompt because that sets special environment variables that define where to look for Python.

It makes sense that Atom would need these environment variables to be set, since it also needs to know where to look for Python in order to start Stata Kernel.

kylebarron avatar Jun 01 '20 04:06 kylebarron

OK that makes sense. I'm excited to get it to work. I love having the inline results. Thanks for developing this.

eteitelbaum avatar Jun 01 '20 05:06 eteitelbaum