Installing Python Modules

合集下载

【Python】pipinstallpycairo-U失败的问题

【Python】pipinstallpycairo-U失败的问题

【Python】pipinstallpycairo-U失败的问题升级pycairo,失败了$ pip install pycairo -UDefaulting to user installation because normal site-packages is not writeableLooking in indexes: https:///simple, https:///simpleRequirement already satisfied: pycairo in /usr/lib/python3/dist-packages (1.16.2)Collecting pycairoUsing cached https:///packages/bc/3f/64e6e066d163fbcf13213f9eeda0fc83376243335ea46a66cefd70d62e8f/pycairo-1.20.1.tar.gz (344 kB) Installing build dependencies ... doneGetting requirements to build wheel ... donePreparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: pycairoBuilding wheel for pycairo (pyproject.toml) ... errorERROR: Command errored out with exit status 1:command: /usr/bin/python3 /home/pi/.local/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpdx40huz4cwd: /tmp/pip-install-vbxqp8qw/pycairo_17a047a1a1314649a235068111ef22e5Complete output (15 lines):running bdist_wheelrunning buildrunning build_pycreating buildcreating build/lib.linux-aarch64-3.7creating build/lib.linux-aarch64-3.7/cairocopying cairo/__init__.py -> build/lib.linux-aarch64-3.7/cairocopying cairo/__init__.pyi -> build/lib.linux-aarch64-3.7/cairocopying cairo/py.typed -> build/lib.linux-aarch64-3.7/cairorunning build_extPackage cairo was not found in the pkg-config search path.Perhaps you should add the directory containing `cairo.pc'to the PKG_CONFIG_PATH environment variableNo package 'cairo' foundCommand '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.----------------------------------------ERROR: Failed building wheel for pycairoFailed to build pycairoERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects安装libcairo2-dev$ sudo apt-get install libcairo2-devReading package lists... DoneBuilding dependency treeReading state information... DoneThe following additional packages will be installed:libcairo-script-interpreter2 libfontconfig1-dev libice-dev libpixman-1-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-devlibxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxdmcp-dev libxext-dev libxrender-dev x11proto-core-dev x11proto-dev x11proto-xext-devxorg-sgml-doctools xtrans-devSuggested packages:libcairo2-doc libice-doc libsm-doc libx11-doc libxcb-doc libxext-docThe following NEW packages will be installed:libcairo-script-interpreter2 libcairo2-dev libfontconfig1-dev libice-dev libpixman-1-dev libpthread-stubs0-dev libsm-dev libx11-devlibxau-dev libxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxdmcp-dev libxext-dev libxrender-dev x11proto-core-dev x11proto-devx11proto-xext-dev xorg-sgml-doctools xtrans-dev0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.Need to get 4,177 kB of archives.After this operation, 13.0 MB of additional disk space will be used.Do you want to continue? [Y/n] yGet:1 /debian buster/main arm64 libfontconfig1-dev arm64 2.13.1-2 [964 kB]Get:2 /debian buster/main arm64 libcairo-script-interpreter2 arm64 1.16.0-4+rpt1 [157 kB]Get:3 /debian buster/main arm64 libpixman-1-dev arm64 0.36.0-1+rpt1 [455 kB]Get:4 /debian buster/main arm64 libcairo2-dev arm64 1.16.0-4+rpt1 [706 kB]Get:5 /debian buster/main arm64 xorg-sgml-doctools all 1:1.11-1 [21.9 kB]Get:6 /debian buster/main arm64 x11proto-dev all 2018.4-4 [251 kB]Get:7 /debian buster/main arm64 x11proto-core-dev all 2018.4-4 [3,128 B]Get:8 /debian buster/main arm64 libxau-dev arm64 1:1.0.8-1+b2 [22.8 kB]Get:9 /debian buster/main arm64 libxdmcp-dev arm64 1:1.1.2-3 [41.2 kB]Get:10 /debian buster/main arm64 xtrans-dev all 1.3.5-1 [100 kB]Get:11 /debian buster/main arm64 libpthread-stubs0-dev arm64 0.4-1 [5,336 B]Get:12 /debian buster/main arm64 libxcb1-dev arm64 1.13.1-2 [174 kB]Get:13 /debian buster/main arm64 libx11-dev arm64 2:1.6.7-1+deb10u2 [816 kB]Get:14 /debian buster/main arm64 libxrender-dev arm64 1:0.9.10-1 [38.8 kB]Get:15 /debian buster/main arm64 x11proto-xext-dev all 2018.4-4 [3,128 B]Get:16 /debian buster/main arm64 libxext-dev arm64 2:1.3.3-1+b2 [104 kB]Get:17 /debian buster/main arm64 libice-dev arm64 2:1.0.9-2 [62.0 kB]Get:18 /debian buster/main arm64 libsm-dev arm64 2:1.2.3-1 [37.4 kB]Get:19 /debian buster/main arm64 libxcb-render0-dev arm64 1.13.1-2 [113 kB]Get:20 /debian buster/main arm64 libxcb-shm0-dev arm64 1.13.1-2 [101 kB]Fetched 4,177 kB in 1min 40s (41.6 kB/s)Selecting previously unselected package libcairo-script-interpreter2:arm64.(Reading database ... 94619 files and directories currently installed.)Preparing to unpack .../00-libcairo-script-interpreter2_1.16.0-4+rpt1_arm64.deb ...Unpacking libcairo-script-interpreter2:arm64 (1.16.0-4+rpt1) ...Selecting previously unselected package libfontconfig1-dev:arm64.Preparing to unpack .../01-libfontconfig1-dev_2.13.1-2_arm64.deb ...Unpacking libfontconfig1-dev:arm64 (2.13.1-2) ...Selecting previously unselected package xorg-sgml-doctools.Preparing to unpack .../02-xorg-sgml-doctools_1%3a1.11-1_all.deb ...Unpacking xorg-sgml-doctools (1:1.11-1) ...Selecting previously unselected package x11proto-dev.Preparing to unpack .../03-x11proto-dev_2018.4-4_all.deb ...Unpacking x11proto-dev (2018.4-4) ...Selecting previously unselected package x11proto-core-dev.Preparing to unpack .../04-x11proto-core-dev_2018.4-4_all.deb ...Unpacking x11proto-core-dev (2018.4-4) ...Selecting previously unselected package libxau-dev:arm64.Preparing to unpack .../05-libxau-dev_1%3a1.0.8-1+b2_arm64.deb ...Unpacking libxau-dev:arm64 (1:1.0.8-1+b2) ...Selecting previously unselected package libxdmcp-dev:arm64.Preparing to unpack .../06-libxdmcp-dev_1%3a1.1.2-3_arm64.deb ...Unpacking libxdmcp-dev:arm64 (1:1.1.2-3) ...Selecting previously unselected package xtrans-dev.Preparing to unpack .../07-xtrans-dev_1.3.5-1_all.deb ...Unpacking xtrans-dev (1.3.5-1) ...Selecting previously unselected package libpthread-stubs0-dev:arm64.Preparing to unpack .../08-libpthread-stubs0-dev_0.4-1_arm64.deb ...Unpacking libpthread-stubs0-dev:arm64 (0.4-1) ...Selecting previously unselected package libxcb1-dev:arm64.Preparing to unpack .../09-libxcb1-dev_1.13.1-2_arm64.deb ...Unpacking libxcb1-dev:arm64 (1.13.1-2) ...Selecting previously unselected package libx11-dev:arm64.Preparing to unpack .../10-libx11-dev_2%3a1.6.7-1+deb10u2_arm64.deb ...Unpacking libx11-dev:arm64 (2:1.6.7-1+deb10u2) ...Selecting previously unselected package libxrender-dev:arm64.Preparing to unpack .../11-libxrender-dev_1%3a0.9.10-1_arm64.deb ...Unpacking libxrender-dev:arm64 (1:0.9.10-1) ...Selecting previously unselected package x11proto-xext-dev.Preparing to unpack .../12-x11proto-xext-dev_2018.4-4_all.deb ...Unpacking x11proto-xext-dev (2018.4-4) ...Selecting previously unselected package libxext-dev:arm64.Preparing to unpack .../13-libxext-dev_2%3a1.3.3-1+b2_arm64.deb ...Unpacking libxext-dev:arm64 (2:1.3.3-1+b2) ...Selecting previously unselected package libice-dev:arm64.Preparing to unpack .../14-libice-dev_2%3a1.0.9-2_arm64.deb ...Unpacking libice-dev:arm64 (2:1.0.9-2) ...Selecting previously unselected package libsm-dev:arm64.Preparing to unpack .../15-libsm-dev_2%3a1.2.3-1_arm64.deb ...Unpacking libsm-dev:arm64 (2:1.2.3-1) ...Selecting previously unselected package libpixman-1-dev:arm64.Preparing to unpack .../16-libpixman-1-dev_0.36.0-1+rpt1_arm64.deb ...Unpacking libpixman-1-dev:arm64 (0.36.0-1+rpt1) ...Selecting previously unselected package libxcb-render0-dev:arm64.Preparing to unpack .../17-libxcb-render0-dev_1.13.1-2_arm64.deb ...Unpacking libxcb-render0-dev:arm64 (1.13.1-2) ...Selecting previously unselected package libxcb-shm0-dev:arm64.Preparing to unpack .../18-libxcb-shm0-dev_1.13.1-2_arm64.deb ...Unpacking libxcb-shm0-dev:arm64 (1.13.1-2) ...Selecting previously unselected package libcairo2-dev:arm64.Preparing to unpack .../19-libcairo2-dev_1.16.0-4+rpt1_arm64.deb ...Unpacking libcairo2-dev:arm64 (1.16.0-4+rpt1) ...Setting up libcairo-script-interpreter2:arm64 (1.16.0-4+rpt1) ...Setting up libfontconfig1-dev:arm64 (2.13.1-2) ...Setting up libpixman-1-dev:arm64 (0.36.0-1+rpt1) ...Setting up libpthread-stubs0-dev:arm64 (0.4-1) ...Setting up xtrans-dev (1.3.5-1) ...Setting up xorg-sgml-doctools (1:1.11-1) ...Processing triggers for libc-bin (2.28-10+rpt2+rpi1) ...Processing triggers for man-db (2.8.5-2) ...Processing triggers for sgml-base (1.29) ...Setting up x11proto-dev (2018.4-4) ...Setting up libxau-dev:arm64 (1:1.0.8-1+b2) ...Setting up libice-dev:arm64 (2:1.0.9-2) ...Setting up libsm-dev:arm64 (2:1.2.3-1) ...Setting up libxdmcp-dev:arm64 (1:1.1.2-3) ...Setting up x11proto-core-dev (2018.4-4) ...Setting up x11proto-xext-dev (2018.4-4) ...Setting up libxcb1-dev:arm64 (1.13.1-2) ...Setting up libx11-dev:arm64 (2:1.6.7-1+deb10u2) ...Setting up libxcb-shm0-dev:arm64 (1.13.1-2) ...Setting up libxcb-render0-dev:arm64 (1.13.1-2) ...Setting up libxext-dev:arm64 (2:1.3.3-1+b2) ...Setting up libxrender-dev:arm64 (1:0.9.10-1) ...Setting up libcairo2-dev:arm64 (1.16.0-4+rpt1) ...重试升级pycairo,成功了$ pip install pycairo -UDefaulting to user installation because normal site-packages is not writeableLooking in indexes: https:///simple, https:///simpleRequirement already satisfied: pycairo in /usr/lib/python3/dist-packages (1.16.2)Collecting pycairoUsing cached https:///packages/bc/3f/64e6e066d163fbcf13213f9eeda0fc83376243335ea46a66cefd70d62e8f/pycairo-1.20.1.tar.gz (344 kB) Installing build dependencies ... doneGetting requirements to build wheel ... donePreparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: pycairoBuilding wheel for pycairo (pyproject.toml) ... doneCreated wheel for pycairo: filename=pycairo-1.20.1-cp37-cp37m-linux_aarch64.whl size=275219 sha256=0c4b0a21f1c8f2aa059678faf6c0e1c3e46ed0f727a1f8e4e96421fe554e98b1 Stored in directory: /home/pi/.cache/pip/wheels/05/3b/2b/3d2f418dab0cb8821d23beb32ee5275ec394c3d5e390ecfc57Successfully built pycairoInstalling collected packages: pycairoSuccessfully installed pycairo-1.20.1。

Python-安装并配置Anaconda环境

Python-安装并配置Anaconda环境

Python-安装并配置Anaconda环境1- 简介官⽹:Anaconda是⼀个⽤于科学计算的Python发⾏版,适⽤于数据分析的Python⼯具,也可以⽤在⼤数据和⼈⼯智能领域。

⽀持 Linux, Mac, Windows系统;包含了Python和相关的配套⼯具,包括许多⾮常有⽤的第三⽅库;利⽤Conda来管理包和运⾏环境,可以很⽅便地解决多版本python并存、切换以及各种第三⽅包安装问题;Conda⽤来管理包(packages)、依赖与环境(environment)的⼯具(可执⾏命令);包管理:与pip类似,conda将所有⼯具、第三⽅包都当做package来管理(包括python和conda⾃⾝),⽽且能够安装⾮python的包;环境管理:可以⽅便地安装各种版本python、各种package、创建虚拟环境并快速切换;⽂档:Getting started:Conda cheat sheet:AnacondaPython的⼀种发⾏版,是⼀个打包的集合(预装好了conda、某个版本的python、众多packages、科学计算⼯具等),占⽤空间较⼤;⽂档:User guide:Getting started:Anaconda cheat sheet:Miniconda只包含最基本的内容(python与conda,以及相关的必须依赖项)的命令⾏⼯具,适合对于空间要求严格的⽤户;Conda与Anaconda的联系与区别Conda可以理解为⼀个⼯具,也是⼀个可执⾏命令,其核⼼功能是包管理与环境管理。

包管理与pip的使⽤类似,环境管理则允许⽤户⽅便地安装不同版本的python并可以快速切换。

Anaconda则是⼀个打包的集合,⾥⾯预装好了conda、某个版本的python、众多packages、科学计算⼯具等等,所以也称为Python的⼀种发⾏版。

2- 安装注意:如⽆特别说明,本⽂内容仅适⽤于windows系统;官⽅下载:清华⼤学anaconda镜像:archive:miniconda:pkgs:下载后根据提⽰进⾏安装,建议安装在指定⽬录,不要选择默认安装路径,以便节约系统盘空间和明确相关路径(例如,虚拟环境的默认路径等)。

Python安装pycurl失败的解决方法

Python安装pycurl失败的解决方法

Python安装pycurl失败的解决⽅法Centos安装pycurlcentos 安装pycurlyum install python-devel curl-develpip3 install pycurlMac(⽼版本)安装pycurl解决MacOS升级后出现xcrun: error: invalid active developer path, missing xcrun的问题xcode-select --install然后dongchang-5:qqmusic baoshan$ pip3 install pycurlCollecting pycurlUsing cached pycurl-7.43.0.1.tar.gzBuilding wheels for collected packages: pycurlRunning setup.py bdist_wheel for pycurl ... doneStored in directory: /Users/baoshan/Library/Caches/pip/wheels/a5/5b/c8/f80900b09b49815e1f90dbae2f57e49b3f4c61071db40fb238 Successfully built pycurlInstalling collected packages: pycurlSuccessfully installed pycurl-7.43.0.1ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)解决办法# pip uninstall pycurl# export PYCURL_SSL_LIBRARY=openssl# pip install pycurldongchang-5:qqmusic baoshan$ pip3 install pycurlCollecting pycurlInstalling collected packages: pycurlSuccessfully installed pycurl-7.43.0.1上述参考⾃:/archives/398dongchang-5:include baoshan$ python3Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import pycurlTraceback (most recent call last):File "<stdin>", line 1, in <module>ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)参考解决⽅案:https:///p/50b6771eb853新版本Mac安装pycurl但是这⾥有⼀个坑:在⾼版本的mac系统环境变量⾥是找不到openssl的头⽂件的因为新版本Mac的openssl版本 LibreSSL 2.2.7pip3 uninstall pycurl# 卸载库export PYCURL_SSL_LIBRARY=opensslexport LDFLAGS=-L/usr/local/opt/openssl/libexport CPPFLAGS=-I/usr/local/opt/openssl/include# openssl相关头⽂件路径pip3 install pycurl --compile --no-cache-dir # 重新编译安装⾄此终于搞定。

python2.7及mysql-python模块安装指南

python2.7及mysql-python模块安装指南

升级至python2.7、mysql-python Linux下安装MySQL笔记本:python相关创建于:2011/11/16 10:57更新于:2011/11/16 10:59 URL:/minglog/archive/2011/4/20.htmlcentos5.x升级至python2.7、mysql-pythoncentos5.3的python版本真让人泪奔,什么时代了还2.4的。

自己动手丰衣足食。

1.从官网下载2.7版本# wget /ftp/python/2.7.1/Python-2.7.1.tar.bz22.安装# tar -jxvf Python-2.7.1.tar.bz2# cd Python-2.7.1# ./configure (如不指定 --prefix,默认安装在/usr/local/lib/python2.7)# make && make install3.升级默认版本# mv python /usr/bin/python24# ln -s /usr/local/bin/python2.7 /usr/bin/python4.安装m ysql-python(安装方法不了解可以参看包内的README)# python setup.py buildTraceback (most recent call last):File "setup.py", line 5, in <module>from setuptools import setup, ExtensionImportError: No module named setuptools什么情况?貌似setuptools没有5.去官网下载setuptools官网下载地址# bash setuptools-0.6c11-py2.7.eggTraceback (most recent call last):File "<string>", line 1, in <module>zipimport.ZipImportError: can't decompress data; zlib not available又是什么情况?缺少zlib?(关于安装python所需的软件环境可参看README)这一步我花了很长时间解决它,过程实在是很让人不爽。

python虚拟环境安装

python虚拟环境安装

python虚拟环境安装virtualenv 是⽤来创建 Python 的虚拟环境的库,虚拟环境能够独⽴于真实环境存在,并且可以同时有多个互相独⽴的 Python 虚拟环境,每个虚拟环境都可以营造⼀个⼲净的开发环境,对于项⽬的依赖、版本的控制有着⾮常重要的作⽤。

虚拟环境有什么意义?打个⽐喻,现在有⼀个 Django 项⽬,使⽤的 Django 版本是1.8,但是系统的 Django 版本已经是更加新的1.11,如果使⽤系统的环境来运⾏项⽬,可能导致很多不兼容,于是,这个问题就可以使⽤⼀个虚拟环境来解决,使⽤ virtualenv 来创建⼀个只给这个项⽬运⾏的开发环境,既可以保证项⽬的正常运⾏,也⽅便了之后移植项⽬。

virtualenv 的安装和使⽤由于 virtualenv 在 Windows 和 linux 上的安装和使⽤有⼀点点不同,所以需要分别来讲。

安装 virtualenvvirtualenv 的安装在 Windows 和 linux 上⾯是⼀样的,所以不分开讲解。

安装 virtualenv 跟安装⼀般的 Python 库是⼀样的操作,直接使⽤pip 命令就⾏了:pip install virtualenv安装完成之后就可以使⽤ virtualenv 的命令来创建虚拟环境了,⾸先需要在 cmd 命令中进⼊需要创建虚拟环境的⽂件夹,⽐如 F 盘的 envs ⽂件夹,然后使⽤以下命令创建⼀个虚拟环境,暂且取名为 new_env:virtualenv new_env可以看到类似如下的结果:F:\envs>virtualenv new_envUsing base prefix 'f:\\python352'New python executable in F:\envs\new_env\Scripts\python.exeInstalling setuptools, pip, wheel...done.上⾯这段返回的意思是使⽤当前系统的 Python 版本创建⼀个虚拟环境使⽤ virtualenv在 Windows 系统上⾯使⽤ virtualenv⾸先进⼊到虚拟环境⽬录中的 Scripts ⽬录:F:\envs>cd new_env\Scripts然后输⼊activate就可以了,会出现如下的结果:(new_env) F:\envs\new_env\Scripts>在地址的前⾯出现了⼀个括号和虚拟环境的名称,这个就表⽰现在已经在虚拟环境 new_env 中了,之后的所有操作都是在虚拟环境中进⾏的,直接输⼊python可以查看当前环境下的 Python 版本,可以得到如下输出:(new_env) F:\envs\new_env\Scripts>pythonPython 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>>使⽤pip的list命令可以查看当前环境下的所有包含的库的版本:(new_env) F:\envs\new_env\Scripts>pip listDEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.pip (9.0.1)setuptools (38.5.2)wheel (0.30.0)在 Linux 上使⽤ virtualenv Linux 上⾯进⼊虚拟环境的⽅式跟 Windows 稍微有点不同,可以直接使⽤命令来进⼊,⽐如同样在 Linux 上⾯的 envs ⽂件夹下⾯有个 new_env 虚拟环境,则直接输⼊以下命令就可以进⼊虚拟环境:$ source new_env/bin/activate同样可以看到类似如下的结果:(new_env) alex@VirtualBox:~/www/envs$进⼊了虚拟环境之后,Windows 和 Linux 上⾯的操作都是⼀样的,这⾥就不单独去说明了。

【Python】pipinstallpycups-U失败的问题

【Python】pipinstallpycups-U失败的问题

【Python】pipinstallpycups-U失败的问题升级pycups,失败了$ pip install pycups -UDefaulting to user installation because normal site-packages is not writeableLooking in indexes: https:///simple, https:///simpleRequirement already satisfied: pycups in /usr/lib/python3/dist-packages (1.9.73)Collecting pycupsUsing cached https:///packages/0c/bb/82546806a86dc16f5eeb76f62ffdc42cce3d43aacd4e25a8b5300eec0263/pycups-2.0.1.tar.gz (62 kB)Preparing metadata (setup.py) ... doneBuilding wheels for collected packages: pycupsBuilding wheel for pycups (setup.py) ... errorERROR: Command errored out with exit status 1:command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2gje3x3g/pycups_d2f734b80021412385c27416075694a2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2gje3x3g/pycups_d2f734b80021412385 cwd: /tmp/pip-install-2gje3x3g/pycups_d2f734b80021412385c27416075694a2/Complete output (12 lines):running bdist_wheelrunning buildrunning build_extbuilding 'cups' extensioncreating buildcreating build/temp.linux-aarch64-3.7aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION="2.0.1" -I/usr/include/python3.7m -c cupsmodule.c -o build cupsmodule.c:24:10: fatal error: cups/cups.h: No such file or directory#include <cups/cups.h>^~~~~~~~~~~~~compilation terminated.error: command 'aarch64-linux-gnu-gcc' failed with exit status 1----------------------------------------ERROR: Failed building wheel for pycupsRunning setup.py clean for pycupsFailed to build pycupsInstalling collected packages: pycupsRunning setup.py install for pycups ... errorERROR: Command errored out with exit status 1:command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2gje3x3g/pycups_d2f734b80021412385c27416075694a2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2gje3x3g/pycups_d2f734b8002141238 cwd: /tmp/pip-install-2gje3x3g/pycups_d2f734b80021412385c27416075694a2/Complete output (14 lines):running install/home/pi/.local/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.setuptools.SetuptoolsDeprecationWarning,running buildrunning build_extbuilding 'cups' extensioncreating buildcreating build/temp.linux-aarch64-3.7aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION="2.0.1" -I/usr/include/python3.7m -c cupsmodule.c -o buil cupsmodule.c:24:10: fatal error: cups/cups.h: No such file or directory#include <cups/cups.h>^~~~~~~~~~~~~compilation terminated.error: command 'aarch64-linux-gnu-gcc' failed with exit status 1----------------------------------------ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2gje3x3g/pycups_d2f734b80021412385c27416075694a2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2g 安装libcups2-dev$ sudo apt-get install libcups2-devReading package lists... DoneBuilding dependency treeReading state information... DoneThe following additional packages will be installed:libcupsfilters-dev libcupsimage2-dev libjbig-dev libjpeg-dev libjpeg62-turbo-dev liblzma-dev libtiff-dev libtiffxx5Suggested packages:liblzma-docThe following NEW packages will be installed:libcups2-dev libcupsfilters-dev libcupsimage2-dev libjbig-dev libjpeg-dev libjpeg62-turbo-dev liblzma-dev libtiff-dev libtiffxx50 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.Need to get 1,549 kB of archives.After this operation, 4,524 kB of additional disk space will be used.Do you want to continue? [Y/n] yGet:1 /debian buster/main arm64 libjbig-dev arm64 2.1-3.1+b2 [28.3 kB]Get:2 /debian buster/main arm64 libcupsfilters-dev arm64 1.21.6-5+rpt1 [177 kB]Get:3 /debian buster/main arm64 libjpeg62-turbo-dev arm64 1:1.5.2-2+deb10u1 [195 kB]Get:4 /debian buster/main arm64 libjpeg-dev all 1:1.5.2-2+deb10u1 [57.7 kB]Get:5 /debian buster/main arm64 liblzma-dev arm64 5.2.4-1 [209 kB]Get:6 /debian-security buster/updates/main arm64 libtiffxx5 arm64 4.1.0+git191117-2~deb10u3 [117 kB]Get:7 /debian-security buster/updates/main arm64 libtiff-dev arm64 4.1.0+git191117-2~deb10u3 [384 kB]Get:8 /debian buster/main arm64 libcupsimage2-dev arm64 2.2.10-6+deb10u4 [19.8 kB]Get:9 /debian buster/main arm64 libcups2-dev arm64 2.2.10-6+deb10u4 [361 kB]Fetched 1,549 kB in 29s (53.5 kB/s)Selecting previously unselected package libjbig-dev:arm64.(Reading database ... 95544 files and directories currently installed.)Preparing to unpack .../0-libjbig-dev_2.1-3.1+b2_arm64.deb ...Unpacking libjbig-dev:arm64 (2.1-3.1+b2) ...Selecting previously unselected package libjpeg62-turbo-dev:arm64.Preparing to unpack .../1-libjpeg62-turbo-dev_1%3a1.5.2-2+deb10u1_arm64.deb ...Unpacking libjpeg62-turbo-dev:arm64 (1:1.5.2-2+deb10u1) ...Selecting previously unselected package libjpeg-dev.Preparing to unpack .../2-libjpeg-dev_1%3a1.5.2-2+deb10u1_all.deb ...Unpacking libjpeg-dev (1:1.5.2-2+deb10u1) ...Selecting previously unselected package liblzma-dev:arm64.Preparing to unpack .../3-liblzma-dev_5.2.4-1_arm64.deb ...Unpacking liblzma-dev:arm64 (5.2.4-1) ...Selecting previously unselected package libtiffxx5:arm64.Preparing to unpack .../4-libtiffxx5_4.1.0+git191117-2~deb10u3_arm64.deb ...Unpacking libtiffxx5:arm64 (4.1.0+git191117-2~deb10u3) ...Selecting previously unselected package libtiff-dev:arm64.Preparing to unpack .../5-libtiff-dev_4.1.0+git191117-2~deb10u3_arm64.deb ...Unpacking libtiff-dev:arm64 (4.1.0+git191117-2~deb10u3) ...Selecting previously unselected package libcupsimage2-dev:arm64.Preparing to unpack .../6-libcupsimage2-dev_2.2.10-6+deb10u4_arm64.deb ...Unpacking libcupsimage2-dev:arm64 (2.2.10-6+deb10u4) ...Selecting previously unselected package libcups2-dev:arm64.Preparing to unpack .../7-libcups2-dev_2.2.10-6+deb10u4_arm64.deb ...Unpacking libcups2-dev:arm64 (2.2.10-6+deb10u4) ...Selecting previously unselected package libcupsfilters-dev:arm64.Preparing to unpack .../8-libcupsfilters-dev_1.21.6-5+rpt1_arm64.deb ...Unpacking libcupsfilters-dev:arm64 (1.21.6-5+rpt1) ...Setting up libjbig-dev:arm64 (2.1-3.1+b2) ...Setting up libjpeg62-turbo-dev:arm64 (1:1.5.2-2+deb10u1) ...Setting up libcupsfilters-dev:arm64 (1.21.6-5+rpt1) ...Setting up liblzma-dev:arm64 (5.2.4-1) ...Setting up libtiffxx5:arm64 (4.1.0+git191117-2~deb10u3) ...Setting up libjpeg-dev (1:1.5.2-2+deb10u1) ...Setting up libtiff-dev:arm64 (4.1.0+git191117-2~deb10u3) ...Setting up libcups2-dev:arm64 (2.2.10-6+deb10u4) ...Setting up libcupsimage2-dev:arm64 (2.2.10-6+deb10u4) ...Processing triggers for libc-bin (2.28-10+rpt2+rpi1) ...Processing triggers for man-db (2.8.5-2) ...重试升级pycups,成功了$ pip install pycups -UDefaulting to user installation because normal site-packages is not writeableLooking in indexes: https:///simple, https:///simpleRequirement already satisfied: pycups in /usr/lib/python3/dist-packages (1.9.73)Collecting pycupsUsing cached https:///packages/0c/bb/82546806a86dc16f5eeb76f62ffdc42cce3d43aacd4e25a8b5300eec0263/pycups-2.0.1.tar.gz (62 kB)Preparing metadata (setup.py) ... doneBuilding wheels for collected packages: pycupsBuilding wheel for pycups (setup.py) ... doneCreated wheel for pycups: filename=pycups-2.0.1-cp37-cp37m-linux_aarch64.whl size=226535 sha256=b76d72547e80daa9c16ec5ad1c45fdaee5fab491a08a9ec8074de9cc975bd264 Stored in directory: /home/pi/.cache/pip/wheels/95/0d/00/287c5f50eb588a8d3d664d252198bdb0f558539843f70f1e89Successfully built pycupsInstalling collected packages: pycupsSuccessfully installed pycups-2.0.1。

Python学习笔记4

Python学习笔记4

Python学习笔记4:编写一个窗口程序上节我们主要学习的是Python的数据和变量。

关于Python的逻辑控制、运算符等在没有“应用”这个层面上起作用的话,不足以引发我们对程序的热情,所以我们就不循规蹈矩了,而是直捣黄龙,敲开应用程序的大门:编写一个窗口程序,并以此为突破开,来学习Python的一些基础知识。

Python是一个模块化的脚本语言,所以要想编写一个“窗口”自然离不开安装“窗口模块”(图形用户界面-->GUI)。

Python“安装”模块用到的命令是:pip。

这个命令在Python目录下的Scripts 目录中。

以我的计算机为例的完整目录是:C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scriptspip命令的使用格式是:pip install 模块文件的完整路径及文件名下面我们把安培wxPython(Python的一种“窗口”模块)的完整过程写出来,以供参考。

1、确定你的Python版本号(版本不对,安装不上)看它的图标上定着:IDLE (Python 3.8 64-bit),这里的“3.8”就是版本号。

如果不信,你可以运行它:2、下载网址:https:///project/wxPython/#files选择对应版本的whl文件下之后把下载的文件考贝到一好输入的路径下(为了输入方便,我是把它放在D:根目录下了)。

3、安装Win(键)+R (运行)cmd回车输入:cd C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts输入:pip install d:\wxPython-4.1.0-cp38-cp38-win_amd64.whl(文件最后安装的细节)好了,完成安装之后就是编个窗口试一试****************************************************************************************** import wx#加载wxPythonapp=wx.App()#创建一个wxPython实例win=wx.Frame(None,title="我的第一个窗口")#创建一个窗口loadButton=wx.Button(win,label="打开",pos=(225,5),size=(80,25))#创建一个按钮saveButton=wx.Button(win,label="保存",pos=(315,5),size=(80,25))#创建一个按钮fileName=wx.TextCtrl(win,pos=(5,5),size=(210,25))#创建一个文本框contents=wx.TextCtrl(win,pos=(5,35),size=(390,260),style=wx.HSCROLL)#创建一个文本框win.Show()#显示窗口app.MainLoop()#进入到事件(消息)循环(实时刷新,以接受新发生的事件)******************************************************************************************程序很简单,在win.Show()之前的语句是我们设计的一个窗口“模型”,使用win.Show()把它展示(制作)出来,接下来就是使用app.MainLoop()监视窗口上的事件变化。

Python中标准模块importlib详解

Python中标准模块importlib详解

Python中标准模块importlib详解1 模块简介Python提供了importlib包作为标准库的⼀部分。

⽬的就是提供Python中import语句的实现(以及__import__函数)。

另外,importlib允许程序员创建他们⾃定义的对象,可⽤于引⼊过程(也称为importer)。

什么是imp?另外有⼀个叫做imp的模块,它提供给Python import语句机制的接⼝。

这个模块在Python 3.4中被否决,⽬的就是为了只使⽤importlib。

这个模块有些复杂,因此我们在这篇博⽂中主要讨论以下⼏个主题:•动态引⼊•检查模块是否可以被引⼊•引⼊源⽂件⾃⾝•第三⽅模块 import_from_github_com2 模块使⽤2.1 动态引⼊importlib模块⽀持传⼊字符串来引⼊⼀个模块。

我们创建两个简单的模块来验证这个功能。

我们将会给予两个模块相同的接⼝,让它们打印名字以便我们能够区分它们。

创建两个模块,分别为foo.py和bar.py,代码如下所⽰,def main():print(__name__)现在我们使⽤importlib来引⼊它们。

让我们看看这段代码如何去做的。

确保你已经把这段代码放在与上⾯创建的两个模块相同的⽬录下。

#importer.pyimport importlibdef dynamic_import(module):return importlib.import_module(module)if __name__ == "__main__":module = dynamic_import('foo')module.main()module_two = dynamic_import('bar')module_two()在这段代码中,我们⼿动引⼊importlib模块,并创建⼀个简单的函数dynamic_import。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

A Glossary
21
B About these documents
27
B.1 Contributors to the Python Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
C History and License
3.3 Alternate installation: Windows (the prefix scheme) . . . . . . . . . . . . . . . . . . . . . . . . 10
4 Custom Installation
11
4.1 Modifying Python’s Search Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
29
C.1 History of the software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
C.2 Terms and conditions for accessing or otherwise using Python . . . . . . . . . . . . . . . . . . . 30
1.1 Best case: trivial installation
In the best case, someone will have prepared a special version of the module distribution you want to install that is targeted specifically at your platform and is installed just like any other software on your platform. For example, the module developer might make an executable installer available for Windows users, an RPM package for users of RPM-based Linux systems (Red Hat, SuSE, Mandrake, and many others), a Debian package for users of Debian-based Linux systems, and so forth. In that case, you would download the installer appropriate to your platform and do the obvious thing with it: run it if it’s an executable installer, rpm --install it if it’s an RPM, etc. You don’t need to run Python or a setup script, you don’t need to compile anything—you might not even need to read any instructions (although it’s always a good idea to do so anyways). Of course, things will not always be that easy. You might be interested in a module distribution that doesn’t have an easy-to-use installer for your platform. In that case, you’ll have to start with the source distribution released by the module’s author/maintainer. Installing from a source distribution is not too hard, as long as the modules are packaged in the standard way. The bulk of this document is about building and installing modules from standard source distributions.
C.3 Licenses and Acknowledgements for Incorporated Software . . . . . . . . . . . . . . . . . . . . 32
D Copyright
41
Index
43
i
ii
Installing Python Modules, Release 2.6.5
5 Distutils Configuration Files
15
5.1 Location and names of config files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Syntax of config files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2 Standard Build and Install
5
2.1 Platform variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Splitting the job up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Installing Python Modules
Release 2.6.5
Guido van Rossum Fred L. Drake, Jr., editor
April 25, 2010
Python Software Foundation Email: docs@
CONTENTS
2.3 How building works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 How installation works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Author Greg Ward Release 2.6 Date April 25, 2010
Abstract This document describes the Python Distribution Utilities (“Distutils”) from the end-user’s point-of-view, describing how to extend the capabilities of a standard Python installation by building and installing thirdparty Python modules and extensions.
6 Building Extensions: Tips and Tricks
17
6.1 Tweaking compiler/linker flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.2 Using non-Microsoft compilers on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1 Introduction
3
1.1 Best case: trivial installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 The new standard: Distutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Alternate Installation
9
3.1 Alternate installation: the home scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Alternate installation: Unix (the prefix scheme) . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
CONTENTS1源自Installing Python Modules, Release 2.6.5
2
CONTENTS
CHAPTER
ONE
INTRODUCTION
Although Python’s extensive standard library covers many programming needs, there often comes a time when you need to add some new functionality to your Python installation in the form of third-party modules. This might be necessary to support your own programming, or to support an application that you want to use and that happens to be written in Python. In the past, there has been little support for adding third-party modules to an existing Python installation. With the introduction of the Python Distribution Utilities (Distutils for short) in Python 2.0, this changed. This document is aimed primarily at the people who need to install third-party Python modules: end-users and system administrators who just need to get some Python application running, and existing Python programmers who want to add some new goodies to their toolbox. You don’t need to know Python to read this document; there will be some brief forays into using Python’s interactive mode to explore your installation, but that’s it. If you’re looking for information on how to distribute your own Python modules so that others may use them, see the Distributing Python Modules (in Distributing Python Modules) manual.
相关文档
最新文档