树莓派python安装第三方库(树莓派python安装第三方库kaleido)

http://www.itjxue.com  2023-03-27 12:36  来源:未知  点击次数: 

python怎么安装第三方类库

使用pip

大多数库都可以通过pip安装,安装方法为,在命令行窗口输入

pip install libname

libname为库名

某些库通过pip安装不了,可能是因为没有打包上传到pypi中,可以下载安装包之后离线安装,方法是

pip install libpath

libpath为本地安装包地址,这些安装包一般以whl为后缀名。表示python扩展包的windows环境下的二进制文件。

有一个专门下载这种文件的地方,是由加利福尼亚大学的师生为方便python用户使用而建立的,并非官方出品,使用时需自行承担风险。

源文件安装

如果下载下来的安装包为带有源文件的压缩包,解压之后,运行setup.py进行安装,方法是

命令行切换到安装包中setup.py文件所在的目录,执行 python setup.py install

运行安装包

有些类库提供了双击运行直接安装的安装包,比如python连接mysql数据库的驱动 mysql-connector-python

这些安装包的后缀名为msi或者exe。下载下来之后,双击运行之后就安装好了,前提是要根据python的版本及windows的位数下载对应的安装包,否则安装过程会报错或者直接提示无法安装。

python 第三方库怎么安装

【方法一】: 通过setuptools来安装python模块

首先下载

NOTE: 最好下载个setuptools,本人是15.2版本,里面包含了ez_setup

运行 python ez_setup.py

D:\work\installation\setuptools-15.2\setuptools-15.2python ez_setup.py 1.txt

Extracting in c:\users\admini~1\appdata\local\temp\tmpbxikxf

Now working in c:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2

Installing Setuptools

......

Copying setuptools-15.2-py2.7.egg to c:\python27\lib\site-packages

setuptools 15.2 is already the active version in easy-install.pth

Installing easy_install-script.py script to C:\Python27\Scripts

Installing easy_install.exe script to C:\Python27\Scripts

Installing easy_install-2.7-script.py script to C:\Python27\Scripts

Installing easy_install-2.7.exe script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-15.2-py2.7.egg

Processing dependencies for setuptools==15.2

Finished processing dependencies for setuptools==15.2

运行 easy_install py

D:\workeasy_install py #py 为第三方库文件

Searching for py

Best match: py 1.4.26

Adding py 1.4.26 to easy-install.pth file

Using c:\python27\lib\site-packages

Processing dependencies for py

Finished processing dependencies for py

【方法二】: 通过pip来安装python模块

安装 easy_install pip

D:\workeasy_install pip

Searching for pip

Best match: pip 6.1.1

Processing pip-6.1.1-py2.7.egg

pip 6.1.1 is already the active version in easy-install.pth

Installing pip-script.py script to C:\Python27\Scripts

Installing pip.exe script to C:\Python27\Scripts

Installing pip2.7-script.py script to C:\Python27\Scripts

Installing pip2.7.exe script to C:\Python27\Scripts

Installing pip2-script.py script to C:\Python27\Scripts

Installing pip2.exe script to C:\Python27\Scripts

Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg

Processing dependencies for pip

Finished processing dependencies for pip

运行 pip install xlrd

Usage:

pip command [options]

Commands:

install Install packages.

uninstall Uninstall packages.

freeze Output installed packages in requirements format.

list List installed packages.

show Show information about installed packages.

search Search PyPI for packages.

wheel Build wheels from your requirements.

zip DEPRECATED. Zip individual packages.

unzip DEPRECATED. Unzip individual packages.

help Show help for commands.

General Options:

-h, --help Show help.

--isolated Run pip in an isolated mode, ignoring

environment variables and user configuration.

-v, --verbose Give more output. Option is additive, and can be

used up to 3 times.

-V, --version Show version and exit.

-q, --quiet Give less output.

--log path Path to a verbose appending log.

--proxy proxy Specify a proxy in the form

[user:passwd@]proxy.server:port.

--retries retries Maximum number of retries each connection should

attempt (default 5 times).

--timeout sec Set the socket timeout (default 15 seconds).

--exists-action action Default action when a path already exists:

(s)witch, (i)gnore, (w)ipe, (b)ackup.

--trusted-host hostname Mark this host as trusted, even though it does

not have valid or any HTTPS.

--cert path Path to alternate CA bundle.

--client-cert path Path to SSL client certificate, a single file

containing the private key and the certificate

in PEM format.

--cache-dir dir Store the cache data in dir.

--no-cache-dir Disable the cache.

--disable-pip-version-check

Don't periodically check PyPI to determine

whether a new version of pip is available for

download. Implied with --no-index.

【方法三】:直接从网上下载下可执行文件来安装.

比如说,去 pythonlibs 网站,提供了很多Python非官方包下载,二进制文件,下载安装方便.

如何在安装pip3以及第三方python库

在安装pip3以及第三方python库(for Mac)

环境

OS:10.12.3 (16D32) macOS Sierra

Python3: Python 3.6.1

什么是pip

Python之所以强大,其中一个原因是其丰富的第三方库。pip则是python第三方库的包管理工具。

由于在Mac上python2和python3是共存的。因而python3对应的包管理工具的命令就是:pip3如何安装pip3如果通过homebrew安装python3,那么pip3会同时安装。所以建议直接通过homebrew安装python3:

$brew install python3//no need sudo

如果你已经通过其他渠道安装了python3但是尚未安装pip3,那么需要通过以下步骤实现安装:

https : // pip.readthedocs .io/en/stable/installing/上述的链接是官方给出的方法,但是有几个地方需要注意,最好按照我博客一步步来:

https : // bootstrap .pypa .io/get-pip.py

复制粘贴另存为链接中的文本,可以保存为get-pip.py。

注意:其中内容很多,必须等网页加载完再复制,然后通过已经安装的python3解释器解释执行另存为的文件$python3 get-pip.py再次执行上述命令,显示:

Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages1安装成功

如何安装第三方库

有了pip3以后,安装第三方库就容易多了,比如:

$pip3 install requests

Collecting requests

Downloading requests-2.13.0-py2.py3-none-any.whl (584kB)100% |████████████████████████████████| 593kB 298kB/sInstalling collected packages: requestsSuccessfully installed requests-2.13.0

如何在树莓派上面安装python

如果为 Raspbian 的话

安装 python: sudo apt-get install python

安装 python3: sudo apt-get install python3

(责任编辑:IT教学网)

更多

推荐linux文章