1. 程式人生 > >hyper-v中搭建本地服務器linux(CentOS 7)的python環境

hyper-v中搭建本地服務器linux(CentOS 7)的python環境

ini scripts under adduser use 搭建 bzip val pac

新建虛擬機->安裝CentOS7->新建虛擬交換機:內部網絡->CentOS7設置->網絡適配器:虛擬交換機:新建虛擬交換機->進入CentOS # cd /etc/sysconfig/network-scripts/ # ls # vi ifcfg-eth0 添加或修改 ONBOOT=yes 保存退出(按ESC再:wq回車) windows中本地網絡連接將以太網與vEthernet橋接 # service network restart 進路由器設置給linux分配靜態IP git安裝 # yum install git -y 安裝python編譯依賴
# yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel # adduser <name>
--------切用戶-------- 安裝pyenv
$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
(若curl出錯(35)SSL connect error ,需要配置一個有校新包的yum源
# vim /etc/yum.repos.d/dvd.repo
添加下文本
[updates]
name=CentOS-Updates
baseurl=https://mirrors.aliyun.com/centos/6.9/os/x86_64
gpgcheck=0
# yum repolist
然後更新nss # yum update nss ~/.bash_profile中追加pyenv
export PATH="/home/python/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)" $ vim ~/.bash_profile 使用pyenv的install安裝所需版本的python
$ pyenv install help
$ pyenv install -l
$ pyenv install 3.7.1 本地安裝
$ cd .pyenv
$ mkdir cache
$ cd cache/ use Xftp copy python-3.7.1.tar.zx&python-3.7.1.tgz to /home/python/.pyenv/cache/ $ pyenv install 3.7.1 若 ModuleNotFoundError: No module named ‘_ctypes‘,其實是缺少了一個新需要的開發包libffi-devel,安裝後即可再返回用戶安裝python
# yum install libffi-devel -y (包在base) 切換python本版 [global 全局設置、shell 用戶設置、local 目錄設置] $ python local 3.7.1 virtualenv 虛擬環境 $ pyenv virtualenv 3.7.1 <Vname>
$ pyenv local <Vname> 創建 .pip 文件夾
$ mkdir .pip
$ cd .pip
$ touch pip.conf
$ vim pip.conf
[global]
index-url=https://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.com
$ cd
$ cd <Vname>
安裝ipython&jupyter和jupyter配置
$ pip install ipython
$ pip install jupyter
首先輸入ipython生成秘鑰
$ ipython
>>>from notebook.auth import passwd
>>>passwd() 使用jupyter前先設置密碼
$ jupyter notebook password
$ jupyert notebook --ip=0.0.0.0 在windows瀏覽器中輸入地址 192.168.xxx.xxx:8888 技術分享圖片
如果windows的瀏覽器連接不上jupyter,有可能是linux 防火墻阻止了,關閉掉 # systemctl stop firewalld port&firewall more: https://www.cnblogs.com/moxiaoan/p/5683743.html 其它可能用到的指令: 查看linux本地端口  打包packages及加載 $ ss -tanl      $ pip freeze > <name>           $ pip install -r <file_packages>

hyper-v中搭建本地服務器linux(CentOS 7)的python環境