You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

远程Putty连接Linux运行Jupyter Notebook遇JS启用问题求助

Fixing "Jupyter Notebook requires Javascript" & Running Python Scripts via PuTTY

Hey there! I get that starting out with remote Jupyter on Linux can feel a bit tricky—let's walk through solving this Javascript error and getting your Python scripts up and running smoothly.

Why You're Seeing the Javascript Error

When you run jupyter notebook directly in PuTTY, you're trying to use Jupyter's browser-based interface through a command-line terminal. Terminals don't support Javascript at all, which is why that error pops up. The fix is to configure Jupyter to let you access it from your local browser (which natively supports Javascript).

Step 1: Configure Jupyter for Remote Access

First, we need to set up Jupyter to accept connections from outside the remote machine:

  1. Generate a Jupyter config file if you don't already have one:
    jupyter notebook --generate-config
    
  2. Open the config file with a text editor (I'll use vim here, but nano works too if you prefer simpler tools):
    vim ~/.jupyter/jupyter_notebook_config.py
    
  3. Find and modify these settings (remove the # comment at the start of each line to activate them):
    • c.NotebookApp.ip = '*' – Allows connections from any IP address
    • c.NotebookApp.open_browser = False – Prevents the remote machine from trying to open a browser (it can't access one via PuTTY anyway)
    • c.NotebookApp.port = 8888 – Uses Jupyter's default port; if this port is already in use, pick another number like 8889
  4. (Optional but highly recommended) Set a password to secure your Jupyter instance:
    jupyter notebook password
    
    Follow the prompts to create a password—you'll need this later to log in from your local browser.

Step 2: Start Jupyter in a Persistent Session

If you close PuTTY, your Jupyter session will stop unless you use a tool to keep it running in the background. Let's use screen (a popular terminal multiplexer):

  1. Install screen if it's not already on your remote machine:
    • For Debian/Ubuntu:
      sudo apt update && sudo apt install screen
      
    • For CentOS/RHEL:
      sudo yum install screen
      
  2. Create a new screen session named "jupyter":
    screen -S jupyter
    
  3. Set your Anaconda path (we'll make this permanent later—see the tip below):
    export PATH="/share/apps/packages/anaconda2/bin:$PATH"
    
  4. Start Jupyter Notebook:
    jupyter notebook
    
  5. Detach the screen session so it keeps running even if you close PuTTY: press Ctrl+A then D. To reattach later (e.g., to stop Jupyter), run screen -r jupyter.

Step 3: Access Jupyter from Your Local Browser

Now, connect to Jupyter using your local computer's browser:

  1. Open any modern browser (Chrome, Firefox, Edge—all have Javascript enabled by default)
  2. Type in the URL: http://[remote-machine-ip]:8888 (replace [remote-machine-ip] with the actual IP address of your remote server)
  3. Enter the password you set earlier (if you completed Step 1.4)
  4. You'll now see the full Jupyter dashboard—no more Javascript errors here!

Running Your Python Scripts in Jupyter

Once you're in the Jupyter dashboard:

  • To create a new notebook: Click the New button in the top-right corner, then select Python 2 (since you're using Anaconda2)
  • To run code in a notebook: Type your Python code into a cell, then press Shift+Enter to execute it. The output will show up right below the cell.
  • To upload an existing Python script: Click the Upload button in the top-right, select your .py file from your local computer, then click the uploaded file to open it in Jupyter (you can run or edit it from there).

Quick Extra Tip: Make Anaconda Path Permanent

Instead of typing the export PATH command every time you log in, add it to your ~/.bashrc file to set it automatically:

echo 'export PATH="/share/apps/packages/anaconda2/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Important Note: Firewall Settings

Make sure your remote machine's firewall allows incoming connections on port 8888 (or whatever port you chose). For example, on Ubuntu with ufw:

sudo ufw allow 8888/tcp

内容的提问来源于stack exchange,提问作者ZEESHAN

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:23:37