Open mikcaf opened 3 years ago
@mikcaf Can you run python -m jupyter --version
and report the output?
@mikcaf Can you run
python -m jupyter --version
and report the output?
jupyter core : 4.6.3 jupyter-notebook : 6.1.4 qtconsole : 4.7.7 ipython : 7.19.0 ipykernel : 5.3.4 jupyter client : 6.1.7 jupyter lab : 2.2.6 nbconvert : 6.0.7 ipywidgets : 7.5.1 nbformat : 5.0.8 traitlets : 5.0.5
@mikcaf Interesting. What about jupyter kernelspec list
?
Also, do you have Stata IC, SE, or MP?
Last, can you run, from Python, from jupyter_client.kernelspec import KernelSpecManager
?
@mcaceresb
When I run jupyter kernelspec list
I receive
Available kernels: stata /Users/MikCaf/Library/Jupyter/kernels/stata python3 /Users/MikCaf/opt/anaconda3/share/jupyter/kernels/python3
I have Stata IC
If I run: python jupyter_client.kernelspec import KernelSpecManager
I receive
python: can't open file 'jupyter_client.kernelspec': [Errno 2] No such file or directory
@mikcaf Start python first, then from inside python run from jupyter_client.kernelspec import KernelSpecManager
@mcaceresb
Sorry for my ignorance, but how exactly do I run Python? Again, I am a novice and I am desperately trying to install the kernel for a College class
@mikcaf Type python
and press enter.
@mikcaf Can you also tell me your version of Python?
@mcaceresb My version of Python is 3.8.5.
When I run on python from jupyter_client.kernelspec import KernelSpecManager Nothing happens(?).
If I run Python, it says Python 3.8.5 (default, Sep 4 2020, 02:22:02) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.
Then I run:
from jupyter_client.kernelspec import KernelSpecManager
and I am back to this:
Does this help?
@mikcaf You installed python via Anaconda? Can you try uninstalling Anaconda and reinstalling? If that doesn't do the trick let me know.
@mcaceresb
I am not sure how I installed Python. By the way, I already uninstalled and re-installed Anaconda a couple of times and I get the same problem again. Should I be able to install the stata kernel even without Anaconda? Because if that is the case, I can tell you that without Anaconda I cannot even use the code:
pip install stata_kernel
@mikcaf I see. You need Python for pip. Let's try this: Uninstall Anaconda and install Python via brew: brew install python
. If you don't have brew, install it first: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then try to install the kernel again.
@mcaceresb For my class, I was asked to use and download Anaconda. Should I install the stata kernel before or after installing Anaconda? I guess my question is: after I install brew and python, should I also install Anaconda and then stata kernel, or can I go directly to stata kernel and then install Anaconda?
@mikcaf While I also tend to recommend Anaconda, I want to figure out if for whatever reason it is clashing with the Stata kernel.
Do not reinstall Anaconda yet.
@mcaceresb I did the first 3 steps, but when I run pip install stata_kernel
I get: -bash: pip: command not found
@mcaceresb
should I use pip3 as a command?
@mikcaf If pip3 and python3 are available then yes, use those.
@mcaceresb
After I run
pip3 install stata_kernel, I get:
Successfully built stata-kernel
when I run,
python3 stata_kernel.install
again I get: Cannot import kernel Installing Jupyter kernel spec
@mcaceresb
sorry, I meant:
python3 -m stata_kernel.install
@mcaceresb do you have any other idea?
You could try downgrading from sur back to the previous osx version. If that is too much of a hassle then I'll need to think for a bit abt what else u could try.
@mcaceresb I think this is probably related to the recent change here https://github.com/kylebarron/stata_kernel/commit/d436d9be8a94858ddbbb5853bfbbf0e852a41ff0#diff-989130b8db8fa5d0d5369619ecb45f2b72696aa855d481b5169c13157ab67b86R5-R8
hence the "Cannot import kernel". I think that block really needs to at least print the caught error...
try:
except error as e:
print(e)
print('cannot import kernel')
@mikcaf Can you uninstall the kernel and reinstall the github version? It should print more detailed error information that might help debug.
pip3 install -U git+https://github.com/kylebarron/stata_kernel
python3 -m stata_kernel.install
Hi, guys. I have the same problem: when I execute in Anconda's prompt
python -m stata_kernel.install
and I get
Cannot import kernel
Installing Jupyter kernel spec
I follow your discussion and their possible solutions; when i'm trying to download the package from GitHub i have this result:
ERROR: Cannot unpack file C:\Users\hp\AppData\Local\Temp\pip-unpack-kc5x_ci6\stata_kernel (downloaded from C:\Users\hp\AppData\Local\Temp\pip-req-build-06gycg6x, content-type: text/html; charset=utf-8); cannot detect archive format ERROR: Cannot determine archive format of C:\Users\hp\AppData\Local\Temp\pip-req-build-06gycg6x
Windows 10 Home Single Languaje (intel core i3) Stata version: 16.1 MP Jupyter-notebook version: 6.1.4
@Ayrton1931 What did you run that gave you the error?
I follow your discussion and their possible solutions; when i'm trying to download the package from GitHub i have this result:
Hi @mcaceresb, i run in anaconda's prompt:
python -m pip install https://github.com/kylebarron/stata_kernel
From above:
pip3 install -U git+https://github.com/kylebarron/stata_kernel python3 -m stata_kernel.install
You need to copy/paste that link
For anyone else facing this issue: After trying several times with different versions of Anaconda and Miniconda installers, I finally had success (following the standard steps on the "Getting Started" page) just using an older version of Miniconda (specifically, Miniconda3 py37_4.8.3). I don't know what the exact problem is, but note that the Miniconda installation page (https://docs.conda.io/en/latest/miniconda.html) only offers versions 2.7, 3.8, and 3.9 of Python, whereas the stata_kernel documentation explicitly states it works with Python versions 3.5, 3.6, and 3.7, so you need to locate an archived version of the installer (like the one I mentioned).
I don't think there's any reason why it shouldn't work with Python 3.8 or 3.9... The restriction in the metadata file is just 3.5+
Yeah, to be clearer, I never received a message specifically about version incompatibility, just the same "Cannot import kernel" error as the previous commenters when trying to use "Miniconda3-py39_4.9.2" or "Anaconda3-2020.11". I have no idea why those newer installers weren't playing nicely.
"Cannot import kernel" error as the previous commenters when trying to use "Miniconda3-py39_4.9.2" or "Anaconda3-2020.11". I have no idea why those newer installers weren't playing nicely.
My first guess is that these newer installers included an updated version of some dependency that broke stata-kernel. This may be related to @mcaceresb 's issues with failing tests here.
One way to test this hypothesis is to install an older miniconda version, such as py37_4.8.3
above, but then update all packages in the environment (I think with conda update --all
). If my theory is right, then importing this package would still fail in the older-then-upgraded environment.
I have followed the discussion but failed trying Python 3.9, 3.7.11, 3.7.7, with Terminal always showing "Cannot import kernel Installing Jupyter kernel spec"
I have successed in Mac 1 year ago, but can't make it in Windows.
I have tried
pip3 install -U git+https://github.com/kylebarron/stata_kernel
python3 -m stata_kernel.install
Then I have the result "Installing Jupyter kernel spec" (without the first line "Cannot import kernel")
@Ayrton1931 What did you run that gave you the error?
I follow your discussion and their possible solutions; when i'm trying to download the package from GitHub i have this result:
I had this issue; frustratingly, the cannot import kernel
message is very opaque, so it took a bit of troubleshooting to find a solution. What ultimately worked for me was to set the stata_path
line of my configuration file explicitly. Apparently, the install step was failing to find the Stata path. Maybe the issue was due to my having multiple versions of Stata installed on my machine.
I still have the same problem as the original poster. I have tried altering the stata_path in the configuration file as well as using Python 3.7.
@kylebarron I'm also running into this same issue if you have any more ideas on what I could try. I also can't find the config file to make any changes there
I had this issue; frustratingly, the
cannot import kernel
message is very opaque, so it took a bit of troubleshooting to find a solution. What ultimately worked for me was to set thestata_path
line of my configuration file explicitly. Apparently, the install step was failing to find the Stata path. Maybe the issue was due to my having multiple versions of Stata installed on my machine.
Hi James, could you clarify which path you set? I tried your solution by setting the path to "/Applications/Stata/StataBE.app/Contents/MacOS/"
. but it didn't work. I would like to check if I specified the path that worked for you. Thanks!
Hi James, could you clarify which path you set? I tried your solution by setting the path to
"/Applications/Stata/StataBE.app/Contents/MacOS/"
. but it didn't work. I would like to check if I specified the path that worked for you. Thanks!
Your path looks right as far as I can tell, though I haven't tried running this kernel on my OSX machine.
I'm running this on Windows so I'm not sure if my solution is OS-specific (it could perhaps not even be the "correct" fix and I instead got lucky after making the change... though I was tweaking things one at a time). Anyways, my config file is simply:
[stata_kernel]
stata_path = "C:/Program Files/Stata17"
execution_mode = automation
cache_directory = ~/.stata_kernel_cache
autocomplete_closing_symbol = False
graph_format = svg
graph_scale = 1
user_graph_keywords = coefplot,vioplot
What at least appears to have pushed me over the edge from "not working" to "working as expected" is setting the path for stata_path
. There's a C:/Program Files/Stata17
install as well as a C:/Program Files/Stata15
legacy install on my machine. On install, this path is supposed to be found automatically, but mine was unluckily blank in the configuration file.
edit to clarify for people not on Windows: The executable StataMP-64.exe
is at C:/Program Files/Stata17/StataMP-64.exe
, so the path set for the config file points directly to the directory with the executable. Same as how @rosieli5 has specified, but for Windows.
Thanks! I also have two different Stata programs. I tried 1) editing the config file as we discussed 2) deleting the obsolete Stata program. Neither worked unfortunately.
Similar issue when installing on a new environment with python=3.9
, jupyter=1.0.0
if using stata_kernel=1.12.2
. If instead, I use stata_kernel=1.11.2
, then things are ok. Not sure what the changes were that may be causing this.
@ozak how did you revert to the previous kernel version?
I had the old version installed in another environment, so executing python -m stata_kernel.install
in the older environment replaced the kernel in the shared location stata /Users/usr/Library/Jupyter/kernels/stata
. But if you do no have it installed in an older environment, I guess you can just use git to go back to the old version or download the older version from pypi.
I have the same problem as the original poster. Tried the above steps with python 3.8.8.
Exact same issue here. It's running fine on my old machine even though I've updated my conda to the latest version, but installation got stuck at this very step on my new machine.
I'm currently running Stata on Jupyter with the pystata magic that Stata 17 supports, but the code I get directly from the notebook is now a .py file rather than a .do file. Typing %%stata in every single chunk is also pretty annoying.
I do really pray that this brilliant kernel can get over this issue. Otherwise newer users might not be able to see it in all its glory.
EDIT: Apparently installing the 1.12.0 version instead will do the trick. Worked for me.
I share the same issue... worked on mac, but failed on windows.
jupyter core : 4.7.1 jupyter-notebook : 6.3.0 qtconsole : 5.0.3 ipython : 7.22.0 ipykernel : 5.3.4 jupyter client : 6.1.12 jupyter lab : 3.0.14 nbconvert : 6.0.7 ipywidgets : 7.6.3 nbformat : 5.1.3 traitlets : 5.0.5
I followed the previous note by Fu-Man-Chu and used: pip install "stata_kernel==1.12.0"
The installation was successful, but need to configure stata_path manually through the configuration file.
The kernel is indeed magical, thanks for the amazing effort in creating this.
I tries an approach and successfully installed stata kernel
I tries an approach and successfully installed stata kernel
- go to 'python_dir\Lib\site-packages\stata_kernel'
- edit 'config.py', replace the value of var 'stata_path' with your stata path, for me it's r'C:\Program Files\Stata17\StataMP-64.exe'
- execute again python -m stata_kernel.install
Thanks, this one solves the problem for me
Fixed this by specifying the Stata executable path in the file .stata_kernel.conf
, under my Users
directory. On line 4, you can find stata_path =
Cannot import kernel Installing Jupyter kernel spec
I tries an approach and successfully installed stata kernel
- go to 'python_dir\Lib\site-packages\stata_kernel'
- edit 'config.py', replace the value of var 'stata_path' with your stata path, for me it's r'C:\Program Files\Stata17\StataMP-64.exe'
- execute again python -m stata_kernel.install
Problem description
I do not know anything about programming, but my class requires me to use a jupyter notebook with stata kernel. When I run the command
pip install stata_kernel
on my terminal, the operation seems successful (I am even able to see the option on jupyter of using the stata kernel).
However, when I run my second command
python -m stata_kernel.install
The terminal says:
Cannot import kernel Installing Jupyter kernel spec
I am not sure if the issues are related, but when I go on jupyter and I try to use the stata kernel, it says connecting, but then after some time it just disconnects (it never says Stata|Idle).
Please, I need help because I need to start submitting assignments on jupyter notebook by Thursday but I cannot make this work!