关于jupyter远程服务器端基于centos8部署和CCXT虚拟货币量化平台搭建详细教程
关于jupyter远程服务器端基于centos8部署和CCXT虚拟货币量化平台搭建详细教程

关于jupyter远程服务器端基于centos8部署和CCXT虚拟货币量化平台搭建详细教程


前言

提示:本人小白,刚入门,在三天左右时间,参考各大教程,来总结和完善一些遇到部署问题等解决方法,欢迎来问,有错误的地方请指正。


一、服务器

       本人购买的是Vultr服务器,服务器的选择和购买以及自己去找文章这里不再叙述。

二、基本安装和配置

1.安装基本

       在安装anaconda,IPython,Jupyter Notebook时,最好安装一些开发操作系统的工具集比如(‘Development Tools‘),省的后期出现问题。

yum update -y
yum install python-pip -y
yum install bzip2 -y
yum groupinstall "Development Tools" -y

       安装出现错误的话自己早度娘来解决问题。一般不会出现问题

2.安装virtualenv和virtualenvwrapper并配置

pip install virtualenv virtualenvwrapper
#如果python3以上版本的使用pip3,如果不知道版本输入以下代码
python -V
#出现两个版本需要卸载一个,以免后面安装ccxt出现错误
nano .bashrc或者.bash_profile
#设置虚拟独立python环境目录
export WORKON_HOME=$root/xxxx
#设置创建项目的目录,后面xxxx可以自己创建一个目录,下面同理
export PROJECT_HOME=$root/xxxx
source /usr/local/bin/virtualenvwrapper.sh
#退出然后运行如下命令
source .bashrc或者.bash_profile

三、Jupyter Notebook安装

1.安装anaconda3(可以忽略直接安装Jupyter Notebook

(1)下载

       从官网(可能比较慢,依照服务器地点而定)

 wget  https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh

或从清华的镜像库里(推荐)

 wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh

反正两种方式都可以,要最新的话自己去官网复制链接前面加wget就行了。

(2)安装

       下面清华清华的镜像库里安装,从官网安装一样,sh+文件名+ -u,文件名不知道使用ls查看即可。

  sh  Anaconda3-5.3.1-Linux-x86_64.sh -u

2.安装Jupyter Notebook

       如果安装了第一步第二步就可以不安装,当然最好再安装一次以防出现错误。

pip install jupyter notebook
#和上面一样,python版本为3以上改成pip3

(1)可能会出现的错误

python.h
error: Setup script exited with error: command 'gcc' failed with exit status 1`

(2)可能解决的方法

python2+

sudo yum -y install gcc
sudo yum install python-devel

python3+

sudo yum install python34-devel
#本人这个成功了

解决方法参考:

https://stackoverflow.com/questions/11094718/error-command-gcc-failed-with-exit-status-1-while-installing-eventlet

3.打开Jupyter Notebook

       使用Jupyter Notebook,一定要先打开看是否有报错,没报错再下一步,否则又要做一遍。亲身经历

Jupyter Notebook

三、Jupyter Notebook远程配置

       从以下两个文章总结,由于方法差不多,只是配置文件不太一样,出现问题可以试试另一个。

https://www.cnblogs.com/andylhc/p/9513504.html
https://www.cnblogs.com/cryWater/p/12941635.html

1.安装Ipyhon生成密钥

(1)安装

pip install ipython
#同上python3+版本用pip3

(2)生成密钥

       为了能安全从远程登陆,需要生成哈希组成的密钥如果有条件可以通过安全认证中心来发放秘钥和认证。
打开ipython,直接输入

ipython
#与上面同理,python3+以上的ipython3.

输入以下两行代码,生成sha1的密码,如下:

from notebook.auth import passwd
passwd()
#输入两次密码确认

       回车出现以下两串中一个,我是下面那个,都一样,复制下来,我删掉了一些,原本很长一串。

#sha1:49acd1a985cc:sdasasdasdasdas
#argon2:$ardsadasdasdsadasdwdawda

2.配置远程

       为了实现员远程,我们要配置自己的服务器信息,来让自己的计算机访问。

(1)生成一个jupyter的配置文件

       不同的计算机生成的地址不一样,输入完会有代码回馈告诉你地址。

jupyter notebook --generate-config
#生成的config file在/root.jupyter/jupyter_notebook_config.py

(1)配置jupyter_notebook_config.py文件

       可以使用emacs或者vim,后面加上jupyter_notebook_config.py地址来编辑配置文件。

emacs /root.jupyter/jupyter_notebook_config.py

不会使用emacs查看以下链接或问度娘

https://blog.csdn.net/jasenwan88/article/details/7690364

写入以下语句,写在后面前面都可以。

c.NotebookApp.ip = '*' 
# 允许访问此jupyter服务器的 IP,星号表示任意 IP,
#如果不设置代表知道你密码的所有IP都可以访问你的服务器,
c.NotebookApp.password = 'sha1:xxx:xxx'
 # 之前生成的密码 hash 字串
c.NotebookApp.open_browser = False
 # 运行时不打开本机浏览器
c.NotebookApp.port = 26888 
# 使用的端口,随意设置
c.NotebookApp.enable_mathjax = True 
# 启用 MathJax

远程服务访问

1.打开端口

(1)开放指定端口

firewall-cmd --zone=public --add-port=1935/tcp --permanent
#中间数字填刚才设置的

成功出现success

2.重启防火墙

 firewall-cmd --reload

结束语

       在其他电脑上网址输入

http://服务器ip地址:端口号/tree

出现界面就算完成了。

       如果安装第三方库如ccxt,直接输入pip install ccxt即可,同理python3以上改为pip3。
       以后还会写一些关于ccxt学习过程,如何使用以及简单委托交易等。

4条评论

  1. Thanks a lot for providing individuals with an exceptionally breathtaking possiblity to read critical reviews from this site. It is usually very useful and full of a great time for me personally and my office co-workers to visit your web site at the least 3 times in a week to see the newest stuff you have. And definitely, I am always pleased with the dazzling knowledge you serve. Certain 2 points in this article are particularly the most impressive I have had. Todd Esposito

  2. I in addition to my buddies came examining the great advice found on your web site and at once got an awful feeling I had not thanked the site owner for those strategies. All of the people are already as a result glad to learn all of them and have in effect in actuality been loving those things. We appreciate you turning out to be very accommodating and also for opting for varieties of magnificent subjects millions of individuals are really desirous to understand about. Our honest regret for not saying thanks to you earlier. Rory Repass

回复 林嬷嬷 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

隐藏
变装