九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
ubuntu普通用戶編譯安裝Python3教程

一、背景

眾所周知,root用戶在linux系統(tǒng)中擁有至高無(wú)上的權(quán)力,為所欲為,想干嘛就干嘛。所以當(dāng)然不能隨隨便便給人家用root賬戶去搞事情啊,這里就有了用普通用戶安裝使用python的想法,一起來(lái)看看吧。

二、前期準(zhǔn)備

更新下源,并安裝相應(yīng)的更新

sudo apt-get install upgrade && apt-get install update

安裝相關(guān)的編譯輔助工具

sudo apt-get install make build-essential zlib1g-dev  -y

-y表示不用你確認(rèn)了,告訴ubuntu你直接給我裝完就行

源碼包下載

認(rèn)準(zhǔn)這個(gè)網(wǎng)站哦,https://www.python.org/downloads/source/, 當(dāng)然你再細(xì)心觀察下,直接訪問(wèn)這里不是更快嗎?https://www.python.org/ftp/python/

三、安裝(以3.8.1為例)

下載相應(yīng)的Python源碼包,這里我們用wget一步到位

wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

對(duì)下載下來(lái)的Python源碼包進(jìn)行解壓

tar -zxvf Python-3.8.1.tgz

這里為了便于管理,我們?cè)诋?dāng)前用戶家目錄下新建software表示我們要裝的軟件,一步到位我們就定義好安裝python的目標(biāo)文件夾了

mkdir -p /home/ataola/software/python3.8

進(jìn)入到解壓后的源碼目錄進(jìn)行編譯安裝

cd Python-3.8.1./configure --prefix="/home/ataola/software/python3.8"make && make install
 

追加到當(dāng)前用戶環(huán)境變量

# 打開(kāi)文件vim ~/.bashrc# 視具體情況粘貼樓下這句話export PATH=PATH/software/python3.8/bin:$PATH# 保存退出 按RSC, 然后輸入:wq# 更新使其生效source ~/.bashrc

驗(yàn)證一下吧

ataola@ataola-ubuntu:~$ python3 -VPython 3.8.1ataola@ataola-ubuntu:~$ pip3 -Vpip 19.2.3 from /home/ataola/software/python3.8/lib/python3.8/site-packages/pip (python 3.8)ataola@ataola-ubuntu:~$ python -VPython 3.8.1ataola@ataola-ubuntu:~$ pip -V
Command 'pip' not found, but can be installed with:
apt install python3-pipPlease ask your administrator.
ataola@ataola-ubuntu:~$

這里你會(huì)發(fā)現(xiàn)每次都要輸入pip3,輸入pip沒(méi)用。你只需在環(huán)境變量加個(gè)別名就好

# 打開(kāi)文件vim ~/.bashrc
# 貼下面的話,視個(gè)人配置alias pip=/home/ataola/software/python3.8/bin/pip3.8
# 保存退出 按RSC, 然后輸入:wq
# 更新使其生效source ~/.bashrc

這樣不就好了嘛

ataola@ataola-ubuntu:~$ python -VPython 3.8.1ataola@ataola-ubuntu:~$ python3 -VPython 3.8.1ataola@ataola-ubuntu:~$ pip -Vpip 19.2.3 from /home/ataola/software/python3.8/lib/python3.8/site-packages/pip (python 3.8)ataola@ataola-ubuntu:~$ pip3 -Vpip 19.2.3 from /home/ataola/software/python3.8/lib/python3.8/site-packages/pip (python 3.8)ataola@ataola-ubuntu:~$

不高興按樓上一步一步來(lái),我這里貼了一份.bashrc,你直接看著改吧

# ~/.bashrc: executed by bash(1) for non-login shells.# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)# for examples
# If not running interactively, don't do anything[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options# ... or force ignoredups and ignorespaceHISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite itshopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)HISTSIZE=1000HISTFILESIZE=10000
# check the window size after each command and, if necessary,# update the values of LINES and COLUMNS.shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot)fi
# set a fancy prompt (non-color, unless we know we "want" color)case "$TERM" in xterm-color) color_prompt=yes;;esac
# uncomment for a colored prompt, if the terminal has the capability; turned# off by default to not distract the user: the focus in a terminal window# should be on the output of commands, not on the prompt#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fifi
if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ 'else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ 'fiunset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dircase "$TERM" inxterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;;*) ;;esac
# enable color support of ls and also add handy aliasesif [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' #alias dir='dir --color=auto' #alias vdir='vdir --color=auto'
alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto'fi
# some more ls aliasesalias ll='ls -alF'alias la='ls -A'alias l='ls -CF'
# Alias definitions.# You may want to put all your additions into a separate file like# ~/.bash_aliases, instead of adding them here directly.# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliasesfi
# enable programmable completion features (you don't need to enable# this, if it's already enabled in /etc/bash.bashrc and /etc/profile# sources /etc/bash.bashrc).#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then# . /etc/bash_completion#fi

搞完以后,這是國(guó)內(nèi)環(huán)境啊,首先想到的是換源啊,不然每次都等個(gè)半死,時(shí)間都浪費(fèi)了,阿里、豆瓣、清華源隨便選一個(gè)吧。

# 升級(jí)pippip install --upgrade pip
# 如果沒(méi)有.pip文件創(chuàng)建,有就略過(guò)mkdir ~/.pip
# 編輯配置文件vim ~/.pip/pip.conf

粘貼如下內(nèi)容

[global]index-url=http://mirrors.aliyun.com/pypi/simple[install]trusted-host=mirrors.aliyun.com

注意這里是走h(yuǎn)ttp的,因?yàn)樽铋_(kāi)始編譯的時(shí)候沒(méi)有選--with-ssl, 當(dāng)然你完全可以重新編譯一次帶上這個(gè)ssl./configure --prefix="/home/ataola/software/python3.8" --enable-optimizations --with-ssl, 后面就可以用https了

試一下安裝速度,起飛

ataola@ataola-ubuntu:~$ pip install wordcloudLooking in indexes: http://mirrors.aliyun.com/pypi/simpleCollecting wordcloud  Downloading http://mirrors.aliyun.com/pypi/packages/50/5b/f588bbd1a7805a742e8d8316740383822b160c4e36b6c14793b57ebe7360/wordcloud-1.8.1-cp38-cp38-manylinux1_x86_64.whl (371 kB)     |████████████████████████████████| 371 kB 3.2 MB/sCollecting matplotlib  Downloading http://mirrors.aliyun.com/pypi/packages/22/1c/d5e535b36c1de4eef4205656e76ac993c6d01b62cfdcac579edb63cd82e0/matplotlib-3.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.3 MB)     |████████████████████████████████| 11.3 MB 129 kB/sRequirement already satisfied: numpy>=1.6.1 in ./software/python3.8/lib/python3.8/site-packages (from wordcloud) (1.21.4)Collecting pillow  Downloading http://mirrors.aliyun.com/pypi/packages/fe/f9/cd8b11ec15e27581c5e7affdf04d618d44fa9524dbeb429e5e728df6dc4c/Pillow-8.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)     |████████████████████████████████| 3.1 MB 47.9 MB/sRequirement already satisfied: python-dateutil>=2.7 in ./software/python3.8/lib/python3.8/site-packages (from matplotlib->wordcloud) (2.8.2)Collecting packaging>=20.0  Downloading http://mirrors.aliyun.com/pypi/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl (40 kB)     |████████████████████████████████| 40 kB 8.1 MB/sCollecting cycler>=0.10  Downloading http://mirrors.aliyun.com/pypi/packages/5c/f9/695d6bedebd747e5eb0fe8fad57b72fdf25411273a39791cde838d5a8f51/cycler-0.11.0-py3-none-any.whl (6.4 kB)Collecting fonttools>=4.22.0  Downloading http://mirrors.aliyun.com/pypi/packages/7d/05/5c446faf632f1a9c386bd9a56555cbcbe6c71e6b523025a4fbde396e9d39/fonttools-4.28.3-py3-none-any.whl (884 kB)     |████████████████████████████████| 884 kB 50.6 MB/sCollecting kiwisolver>=1.0.1  Downloading http://mirrors.aliyun.com/pypi/packages/d0/2c/c3cba6c1ec54c82bfc56204c712dd2e9b069e2590f78a18841dafbdf2ced/kiwisolver-1.3.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB)     |████████████████████████████████| 1.2 MB 47.2 MB/sCollecting pyparsing>=2.2.1  Downloading http://mirrors.aliyun.com/pypi/packages/a0/34/895006117f6fce0b4de045c87e154ee4a20c68ec0a4c9a36d900888fb6bc/pyparsing-3.0.6-py3-none-any.whl (97 kB)     |████████████████████████████████| 97 kB 10.9 MB/sRequirement already satisfied: six>=1.5 in ./software/python3.8/lib/python3.8/site-packages (from python-dateutil>=2.7->matplotlib->wordcloud) (1.16.0)Installing collected packages: pyparsing, pillow, packaging, kiwisolver, fonttools, cycler, matplotlib, wordcloudSuccessfully installed cycler-0.11.0 fonttools-4.28.3 kiwisolver-1.3.2 matplotlib-3.5.1 packaging-21.3 pillow-8.4.0 pyparsing-3.0.6 wordcloud-1.8.1ataola@ataola-ubuntu:~$

四、使用

輸入Python,隨便打點(diǎn)什么吧

ataola@ataola-ubuntu:~$ pythonPython 3.8.1 (default, Dec 11 2021, 19:38:06)[GCC 9.3.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import thisThe Zen of Python, by Tim Peters
Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea -- let's do more of those!>>>

python吧,就是包庫(kù)多,有的時(shí)候我們可能期望 a和b組合做一個(gè)實(shí)驗(yàn)或者開(kāi)發(fā), 有的時(shí)候期望是a和c組合,那么這里推薦你用virtualenv

# 安裝virtualenvpip install virtualenv
# 創(chuàng)建項(xiàng)目文件并進(jìn)入mkdir play-py-a && cd play-py-a
## 創(chuàng)建虛擬環(huán)境python -m venv venv

詳細(xì)信息如下:

ataola@ataola-ubuntu:~/play-py-a/venv/bin$ lsactivate  activate.csh  activate.fish  Activate.ps1  easy_install  easy_install-3.8  pip  pip3  pip3.8  python  python3  python3.8ataola@ataola-ubuntu:~/play-py-a/venv/bin$ pwd/home/ataola/play-py-a/venv/binataola@ataola-ubuntu:~/play-py-a/venv/bin$具體的可以看這里,https://virtualenv.pypa.io/en/latest/
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
深入體驗(yàn)bash on windows!在windows上搭建原生的linux
ubuntu16.04將python2改為python3并安裝pip3最新版
在Ubuntu下配置舒服的Python開(kāi)發(fā)環(huán)境
windows下pip安裝和安裝包時(shí)指定源
Ubuntu無(wú)法找到add
Ubuntu命令行提示符參數(shù)
更多類似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服