Ubuntu 编译安装python3.7
生活随笔
收集整理的這篇文章主要介紹了
Ubuntu 编译安装python3.7
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
一、環(huán)境:
Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-131-generic x86_64)
二、軟件下載:
https://www.python.org/downloads/
https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
三、升級系統(tǒng):
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade四、安裝所需的組件:
sudo apt-get install build-essential bzip2 gcc libbz2-1.0 libbz2-dev libc6-dev libdb-dev libexpat1 sudo apt-get install libexpat1-dev libffi-dev libgdbm-dev libgdbm3 liblzma-dev libncurses5-dev libncursesw5-dev sudo apt-get install libpcap-dev libreadline-dev libreadline5 libreadline6 libreadline6-dev sudo apt-get install libsqlite0 libsqlite0-dev libsqlite3-0 libsqlite3-dev libssl-dev libssl1.0.0 sudo apt-get install libxml2-dev libxslt1-dev make openssl python-dev python-pip python-setuptools sudo apt-get install python-smbus python3-dev sqlite sqlite3 tcl tk tk-dev uuid-dev xz-utils zlib1g zlib1g-dev
五、編譯python3.7.1
tar zxvf Python-3.7.1.tgz
cd Python-3.7.1
./configure --prefix=/usr/local/python371 --enable-optimizationsexport CPPFLAGS=" -Wno-error=coverage-mismatch"
make -j9sudo ln -s /usr/local/python371/bin/python3 /usr/bin/python371
sudo ln -s /usr/local/python371/bin/python3 /usr/bin/python3.7.1
sudo ln -s /usr/local/python371/bin/pip3 /usr/bin/pip371
sudo ln -s /usr/local/python371/bin/pip3 /usr/bin/pip3.7.1
六、編譯python3.7.0
tar zxvf Python-3.7.0.tgz cd Python-3.7.0sed -i "6s/endif/else/" ./Modules/_uuidmodule.c sed -i "7d" ./Modules/_uuidmodule.c sed -i "s/Werror=implicit-function-declaration/Wno-error/g" ./configure./configure --prefix=/usr/local/python370 --enable-optimizations? make -j9sudo ln -s /usr/local/python370/bin/python3 /usr/bin/python370? sudo ln -s /usr/local/python370/bin/python3 /usr/bin/python3.7.0? sudo ln -s /usr/local/python370/bin/pip3 /usr/bin/pip370? sudo ln -s /usr/local/python370/bin/pip3 /usr/bin/pip3.7.0七、其他命令
adduser?zhangsan usermod -a -G sudo,root zhangsansudo lsb_release -a八、python3.7.1出現(xiàn)的錯誤
1.-Werror=implicit-function-declaration
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -DHAVE_NCURSESW=1 -I/usr/include/ncursesw -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -Imydownload/Python-3.7.0/Include -Imydownload/Python-3.7.0 -c mydownload/Python-3.7.0/Modules/_cursesmodule.c -o build/temp.linux-x86_64-3.7mydownload/Python-3.7.0/Modules/_cursesmodule.o mydownload/Python-3.7.0/Modules/_cursesmodule.c: In function ‘PyCurses_setupterm’: mydownload/Python-3.7.0/Modules/_cursesmodule.c:2564:35: error: implicit declaration of function ‘setupterm’ [-Werror=implicit-function-declaration]if (!initialised_setupterm && setupterm(termstr,fd,&err) == ERR) {^ cc1: some warnings being treated as errors building '_curses_panel' extension gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -DHAVE_NCURSESW=1 -I/usr/include/ncursesw -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -Imydownload/Python-3.7.0/Include -Imydownload/Python-3.7.0 -c mydownload/Python-3.7.0/Modules/_curses_panel.c -o build/temp.linux-x86_64-3.7mydownload/Python-3.7.0/Modules/_curses_panel.o gcc -pthread -shared build/temp.linux-x86_64-3.7mydownload/Python-3.7.0/Modules/_curses_panel.o -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -lpanelw -lncursesw -o build/lib.linux-x86_64-3.7/_curses_panel.cpython-37m-x86_64-linux-gnu.so *** WARNING: renaming "_curses_panel" since importing it failed: No module named '_curses'Python build finished successfully! The necessary bits to build these optional modules were not found: _hashlib _ssl To find the necessary bits, look in setup.py in detect_modules() for the module's name.The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc atexit pwd time解決方式:修改configure文件(sed -i "s/Werror=implicit-function-declaration/Wno-error/g" configure)
2.錯誤:unknown type name ‘uuid_t’ 和錯誤-Werror=coverage-mismatch
CC='gcc -pthread' LDSHARED='gcc -pthread -shared ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py -q build mydownload/Python-3.7.1/Modules/binascii.c: In function ‘binascii_crc32’: mydownload/Python-3.7.1/Modules/binascii.c:1610:1: error: the control flow of function ‘binascii_crc32’ does not match its profile data (counter ‘a(chǎn)rcs’) [-Werror=coverage-mismatch]}^ mydownload/Python-3.7.1/Modules/binascii.c:1610:1: error: the control flow of function ‘binascii_crc32’ does not match its profile data (counter ‘time_profiler’) [-Werror=coverage-mismatch] cc1: some warnings being treated as errors mydownload/Python-3.7.1/Modules/_uuidmodule.c: In function ‘py_uuid_generate_time_safe’: mydownload/Python-3.7.1/Modules/_uuidmodule.c:15:5: error: unknown type name ‘uuid_t’uuid_t uuid;^ mydownload/Python-3.7.1/Modules/_uuidmodule.c:32:5: error: implicit declaration of function ‘uuid_generate_time’ [-Werror=implicit-function-declaration]uuid_generate_time(uuid);^ mydownload/Python-3.7.1/Modules/_uuidmodule.c:33:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]return Py_BuildValue("y#O", (const char *) uuid, sizeof(uuid), Py_None);^ cc1: some warnings being treated as errorsThe following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc atexit pwd time Failed to build these modules: _uuid binascii?解決方法:設(shè)定環(huán)境變量(export CPPFLAGS=" -Wno-error=coverage-mismatch")修改文件
?
轉(zhuǎn)載于:https://my.oschina.net/mengyoufengyu/blog/2876198
總結(jié)
以上是生活随笔為你收集整理的Ubuntu 编译安装python3.7的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: spring-data-redis版本冲
- 下一篇: 嵌入式小白到大神学习全攻略(学习路线+课