简体   繁体   中英

Setting up Hydrogen and Atom with Anaconda on Windows

I would like to run python interactively in ATOM using the Hydrogen package. I would like to be able to initiate an ATOM session by double-clicking the ATOM icon in my toolbar or double-clicking a .py file and not have to resort to initiating ATOM via the command line. I am on Windows 10. I have installed Python 3.8 via the Anaconda distribution. I have used pip install to install the ipykernel.

I get a series of Traceback errors which seems to be common;

Traceback (most recent call last): File "C:\Users\BRB\anaconda3\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\BRB\anaconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\BRB\anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Users\BRB\anaconda3\lib\site-packages\ipykernel__init__.py", line 2, in from .connect import File "C:\Users\BRB\anaconda3\lib\site-packages\ipykernel\connect.py", line 18, in import jupyter_client File "C:\Users\BRB\anaconda3\lib\site-packages\jupyter_client__init__.py", line 4, in from .connect import File "C:\Users\BRB\anaconda3\lib\site-packages\jupyter_client\connect.py", line 21, in import zmq File "C:\Users\BRB\anaconda3\lib\site-packages\zmq__init__.py", line 47, in from zmq import backend File "C:\Users\BRB\anaconda3\lib\site-packages\zmq\backend__init__.py", line 40, in reraise(*exc_info) File "C:\Users\BRB\anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise raise value File "C:\Users\BRB\anaconda3\lib\site-packages\zmq\backend__init__.py", line 27, in _ns = select_backend(first) File "C:\Users\BRB\anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend mod = import(name, fromlist=public_api) File "C:\Users\BRB\anaconda3\lib\site-packages\zmq\backend\cython__init__.py", line 6, in from . import (constants, error, message, context, ImportError: DLL load failed while importing error: The specified module could not be found.

Things I have tried:

  1. I first added the Python3 executable to the system PATH (against the advice of Anaconda). This does work if I initiate ATOM via the command line, but if I double-click the ATOM icon or .py file, I get the usual traceback errors.

This answer https://discuss.atom.io/t/solved-how-to-use-the-hydrogen-package/30190 says it was a problem with Atom on macOS machines on older versions of Atom but has since been corrected for macOS. The answer was 4 years ago, so I assume it has been corrected for Windows, but I cannot find a soltion.

  1. This answer Setting up Hydrogen and Atom with Anaconda managing python installation says to (A) run:

    conda activate myenv python -m ipykernel install --user

and (B) clean up the PATH.

I did do both of these things. Removing the Python3 executable from PATH was a step backwards. Now it doesn't work even from the command line. I also don't understand why this is even bad in the first place...

  1. This guy Atom: Setting up Hydrogen Launcher for use with Python 3.7 has the same problems. But no solution.

Can someone point me in the right direction?

I am relatively new so would prefer not to complicate things by setting up multiple virtual environments etc at this stage (I don't yet have a need and I want simple).

I use Atom + Hydrogen extensively. And it is works which whatever python version and if it uses Anaconda, Miniconda, or simply python. Please do not mess with the system environment PATH . Maybe you are confused about which python executable is which. So, I am sure that Atom.exe uses the default python version first listed in an environment variable. But for Hydrogen, it will use a registered kernel of python executables.

I install several python versions (Yup, sorry I don't use pipenv) for example:

  • python37 in D:\\python\\python37\\python.exe
  • python38 in D:\\python\\python38\\python.exe

If I want to use the python37 kernel, I will register the kernel with:

D:\python\python37\python.exe -m ipykernel install --name 'python37'

or with python38

D:\python\python38\python.exe -m ipykernel install --name 'python38'

But yes, I always use a virtual environment. So if I want to use a virtual environment named 'work' with Hydrogen, I should register it for the first time.

workon work
python -m ipykernel install --name 'work venv'

Here is the example of my kernel: 在此处输入图片说明

So I think you already have the answer to your question inside your question itself, maybe remove the --user argument and set --name because, you know, it will replace the existing kernel with the same name:

conda activate myenv
python -m ipykernel install --name 'some env'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM