【星海随笔】Centos8试用jupyter问题合集

CentOS 8 如何切换源?

本人使用的是阿里云的微服务

rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
wget http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
wget http://mirrors.cloud.aliyuncs.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g'  /etc/yum.repos.d/Centos-vault-8.5.2111.repo &&  sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
yum clean all && yum makecache

安装python也需要安装很多配件
安装jupter遇到的问题

yum -y install python3-pip
pip3 install pylint
python -m pip install --upgrade --force pip 
pip install jupyter

查看jupyter的配置文件路径

jupyter-notebook --generate-config --allow-root

终端启动

jupyter-notebook --allow-root

后台启动

nohup jupyter notebook --allow-root > /jupyter/jupyter.log 2>&1 &

nginx配置一下jupter

server {
   server_name __;
   listen 8000;

    location / {
        proxy_pass http://127.0.0.1:8888;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
    }
}

以上的listen和proxy有冲突会导致,访问web IP 出现400 bad

设置jupter的这个参数为True

 c.NotebookApp.allow_remote_access = True

否则报 403 : Forbidden

忘记登录密码
重置密码

jupyter notebook --generate -config

无法打开代码框

#打开jupyter_notebook_config.py文件
#找到
c.NotebookApp.allow_origin = ' '
#' '改为‘*’

安装一些pip包,需要再虚拟环境中安装使用

root@DevelopmentNode ~ $ python3 -m venv tutorial-env
root@DevelopmentNode ~ $ source tutorial-env/bin/activate

安装request 失败
ERROR: Could not find a version that satisfies the requirement request (from versions: none)
ERROR: No matching distribution found for request

 pip install request -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

遇到有一个奇怪的问题 pandas不是panda

import pandas as pd 

版权声明:本文为weixin_41997073原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。