SoFunction
Updated on 2024-12-10

Using Atom to support Jupyter-based Python open tutorial details

There is relatively little online information about the use of Atom for Python development, recently found that the use of Atom combined with the Hydrogen plug-in for Python development, especially data mining-related work, the overall experience is better than Vscode, Vscode, although it is said that there is also a connection to Jupyter's tools, but the interactive development Hydrogen experience better.

Here's a motion picture to show how powerful Hydrogen is

Plug-in Installation

Python

  • Hydrogen
  • atom-ide-ui
  • ide-python 

Note that the local pip needs to install python-language-server[all], as described in the readme for ide-python.

remote connection

  • Remote FTP
  • beautification
  • simplified-chinese-menu (Chinese language patch)
  • file-icons (folder icons)
  • bracket-colorizer (rainbow brackets, searched for a long time and determined that it just had to match the dark theme)
  • atom-bracket-highlight
  • atom-clock (add a clock in the lower right corner)
  • highlight-selected
  • minimap (similar to sublime's right map bar)
  • minimap-highlight-selected (after selecting a code, the map is also highlighted on the map to make it easier to locate the code)

Plug-in Configuration

Remote FTP

Here is a little bit about my needs, I need to use it to connect to the content on the company's server, but the company's server is required to jumpstart the machine, so I need to go through the jumpstart machine in order to access, so the configuration will be a little bit complicated

{
    "protocol": "sftp",
    "host": "Skipjack domain name", // string - Hostname or IP address of the server. Default: 'localhost'
    "port": Skipping machine port, // integer - Port number of the server. Default: 22
    "user": "Username", // string - Username for authentication. Default: (none)
    "pass": "If you use a key, you don't have to fill it in here.", // string - Password for password-based user authentication. Default: (none)
    "promptForPass": false, // boolean - Set to true for enable password/passphrase dialog. This will prevent from using cleartext password/passphrase in this config. Default: false
    "remote": "The actual server directory, e.g. /server domain/username/directory", // try to use absolute paths starting with /
    "agent": "", // string - Path to ssh-agent's UNIX socket for ssh-agent-based user authentication. Linux/Mac users can set "env" as a value to use env SSH_AUTH_SOCK variable. Windows users: set to 'pageant' for authenticating with Pageant or (actual) path to a cygwin "UNIX socket." Default: (none)
    "privatekey": "Local private key path", // string - Absolute path to the private key file (in OpenSSH format). Default: (none)
    "passphrase": "", // string - For an encrypted private key, this is the passphrase used to decrypt it. Default: (none)
    "hosthash": "", // string - 'md5' or 'sha1'. The host's key is hashed using this method and passed to the hostVerifier function. Default: (none)
    "ignorehost": true,
    "connTimeout": 10000, // integer - How long (in milliseconds) to wait for the SSH handshake to complete. Default: 10000
    "keepalive": 10000, // integer - How often (in milliseconds) to send SSH-level keepalive packets to the server (in a similar way as OpenSSH's ServerAliveInterval config option). Set to 0 to disable. Default: 10000
    "keyboardInteractive": If a dynamic token is to be used,This is where you have to fill in thetrue, // boolean - Set to true for enable verifyCode dialog. Keyboard interaction authentication mechanism. For example using Google Authentication (Multi factor)
    "keyboardInteractiveForPass": false, // boolean - Set to true for enable keyboard interaction and use pass options for password. No open dialog.
    "remoteCommand": "",
    "remoteShell": "",
    "watch":[],
    "watchTimeout":500, // integer - The duration ( in milliseconds ) from when the file was last changed for the upload to begin.
}

ide-python

It needs to be configured.Python Executable

Fill in your python path, for example, if you are using the conda virtual environment, write it like this

/xxx/anaconda3/envs/xxx/bin/python

Hydrogen

Connecting to the local Kernel

The first thing you need to do is to install the python environment in the path you filled in above.ipykernel

python -m ipykernel install --user --name py37

Then open a py file with atom and type in

# %%
print('hello atom')

# %%
print('Each # %% represents a new cell')

Then press ctrl+enter at the end of the 2nd line and a pop-up window will automatically appear allowing you to select the environment, select the environment you just created.

And then inside Hydrogen by using the# %%to split each cell, in Mac use option+shift+enter to run the entire current ceil, use command+enter to run the current line, use shift+enter to run the current line and jump to the next line, you can refer to the official document for details.

Connecting to the Remote Kernel

To connect to a remote Jupyter you just need to configure the Hydrogen settings inside theKernel Gateways, just fill in the following

[{"name": "Remote server",
  "options": {
    "baseUrl": "jupyter url",
    "token": "jupyter token"
  }
}]

Then clickConnect to Remote Kernelcan immediately (do sth)

To this point this article on the use of Atom support Jupyter-based Python development article is introduced to this, more related Atom Jupyter-based Python development content please search for my previous posts or continue to browse the following related articles I hope you will support me in the future !