jupyer配置vpn

方式一:命令行启动jupyter,网页运行

clash
#另开窗口
proxychains4 jupyter notebook
#遇到要输入token或者密码
jupyter server list
#输出结果 可直接访问链接进入网页 也可以将token复制输入进入
Currently running servers:
http://localhost:8888/?token=6dfa4d91bcf91e6156f649fbe39fb809526750eeb37c67b9 :: /home/win/16t2/study/deep_learning/gene/project/dnagpt2

方式二:在 Jupyter Notebook代码框内部配置代理

import requests

# 设置代理
proxies = {
"http": "http://127.0.0.1:7890",
"https": "https://127.0.0.1:7890"
}
#http://<proxy_ip>:<proxy_port>
# 使用代理发送请求
response = requests.get("http://google.com", proxies=proxies)
print("Status Code:", response.status_code)
print("Response Text:", response.text)
#返回状态码为200即返回成功


#或者
import os
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'https://127.0.0.1:7890'
------ 本文结束 🎉🎉 谢谢观看 ------
0%