Python虚拟环境 / Jupyter notebook / VS Code 远程连接

Python虚拟环境

1.进入/home/123/env/

2.执行virtualenv -p=python3.7 --system-site-packages 环境名称

3.进入环境目录

4.source bin/activate

5.安装必要的库 pip install -r requirement.txt

6.添加核kernel for notebook

/home/123/env/环境名/bin/python -m ipykernel install --name 核名

requirement.txt文件自己添加库名称,每行一个:

cython
numpy
torch>=1.3
albumentations>=0.3.2
mmcv
torchvision
matplotlib
Pillow<=6.2.2
pycocotools@git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools
torchvision

Jupyter notebook

# 安装
pip install jupyter

# 生成配置文件
jupyter notebook --generate-config

# 生成密码
jupyter notebook password

# 修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py
# 添加以下内容
#####################################
c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.password = u'sha:ce...上面生成的密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口
#####################################

VS Code 远程连接

1.配置VS Code中的.ssh/config

Host lzy
    HostName 10.24.11.22
    User lzy
  1. 免密码连接

本地电脑cmd执行ssh-keygen生成C:\Users\lzy\.ssh\id_rsa.pub上传的服务器~/.ssh/目录下

执行cat id_rsa.pub >> authorized_keys service ssh restart

在xshell中激活X11转发功能

如要使用X11转发服务,需对Xshell和SSH服务器进行设置,具体操作如下:

1.打开会话对话框。

2.选择要激活X11转发功能的会话。

3.点击[属性]按钮。

4.在[类别]中选择[连接: SSH: 隧道]

猜你喜欢

转载自www.cnblogs.com/linzhenyu/p/13376855.html