1、安裝pyenvpython
#系統環境 # cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 一、安裝git # yum -y install git 二、安裝pyenv # curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash 或者參考:https://github.com/yyuu/pyenv-installer 三、配置環境變量 # vim /etc/profile.d/pyenv.sh #定義的全局環境變量 export PATH="/root/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" # . /etc/profile.d/pyenv.sh #載入一下
2、安裝pythongit
一、安裝編譯工具 # yum -y install gcc make patch 二、安裝依賴環境 # yum -y install gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel 三、升級pyenv(最新版本3.2也許沒有在pyenv中) # pyenv update 四、安裝python3.5.2 # pyenv install 3.5.2 #這塊可能安裝比較慢,須要等待一會。 五、使用國內鏡像安裝 # mkdir ~/.pyenv/cache # wget -c http://7d9qvq.com1.z0.glb.clouddn.com/Python-3.5.2.tgz # mv Python-3.5.2.tar.gz ~/.pyenv/cache/Python-3.5.2.tar.gz # pyenv install 3.5.2
3、pyenv基本使用方法github
一、local命令 # pyenv versions * system (set by /root/.pyenv/version) 3.5.2 # pyenv local 3.5.2 #切換到3.5.2 # python -V Python 3.5.2 #已經切換成功 二、global命令 # pyenv global 3.5.2 #全局切換至3.5.2版本,不建議使用這條命令 三、virtualenv命令 # pyenv virtualenv 3.5.2 bjwf #以3.5.2爲模版建立python3.5.2虛擬環境bjwf # ll ~/.pyenv/versions/ 3.5.2 bjwf -> /root/.pyenv/versions/3.5.2/envs/bjwf 四、uninstall命令 # pyenv uninstall bjwf #卸載某個版本(包括虛擬環境版本) pyenv-virtualenv: remove /root/.pyenv/versions/3.5.2/envs/bjwf? y # ll ~/.pyenv/versions/ drwxr-xr-x 7 root root 63 Jun 30 05:50 3.5.2 五、其餘命令 # pyenv install –list #列出可安裝的版本 # pyenv rehash #更新數據庫 # pyenv versions #查看當前已安裝的全部版本 # pyenv global 3.5.2 #建議永遠不要執行 # pyenv help #查看幫助 Usage: pyenv <command> [<args>] Some useful pyenv commands are: commands List all available pyenv commands local Set or show the local application-specific Python version global Set or show the global Python version shell Set or show the shell-specific Python version install Install a Python version using python-build uninstall Uninstall a specific Python version rehash Rehash pyenv shims (run this after installing executables) version Show the current Python version and its origin versions List all Python versions available to pyenv which Display the full path to an executable whence List all Python versions that contain the given executable See `pyenv help <command>' for information on a specific command. For full documentation, see: https://github.com/yyuu/pyenv#readme
4、安裝ipython,jupytersql
一、配置國內鏡像(pipe) # mkdir ~/.pip # vim ~/.pip/pip.conf [global] #阿里 index-url = http://mirrors.aliyun.com/pypi/simple/ trusted-host = mirrors.aliyum.com [global] #豆瓣 index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com disable-pip-version-check = true timeout = 120 二、安裝ipython # pip install --upgrade pip #我這塊提高要先安裝這個 # pip install ipyton # ipython #能夠使用了 Python 3.5.2 (default, Jun 30 2016, 05:24:18) Type "copyright", "credits" or "license" for more information. IPython 4.2.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: print('hello world') hello world 三、安裝jupyter # pip install jupyter # # jupyter-notebook --ip=0.0.0.0 --port=8888 --no-browser #前臺運行 [I 06:24:43.608 NotebookApp] Serving notebooks from local directory: /root [I 06:24:43.609 NotebookApp] 0 active kernels [I 06:24:43.609 NotebookApp] The Jupyter Notebook is running at: http://0.0.0.0:8888/ [I 06:24:43.609 NotebookApp] Use Control-C to stop this server and shut down all kernels [I 06:24:58.443 NotebookApp] 302 GET / (192.168.110.253) 2.11ms [I 06:25:26.260 NotebookApp] Creating new notebook in # nohup jupyter-notebook --ip=0.0.0.0 --port=8888 --no-browser & #後臺運行