在python 3.8中利用旧版pip.pyz安装pandas
·
系统是python 3.8,并且未安装pip。
aaa@kylin-pc:~/par$ python3
Python 3.8.10 (default, Feb 20 2025, 02:54:46)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
aaa@kylin-pc:~/par$ pip3
Could not find command-not-found database. Run 'sudo apt update' to populate it.
pip3:未找到命令
用以前下载的pip.pyz提示版本太新,python 3.8不支持。到https://bootstrap.pypa.io/pip/zipapp/下载一个看上去更旧的版本
aaa@kylin-pc:~/par$ python3 pip.pyz list installed
This version of pip does not support python 3.8 (requires >= 3.9).
Index of /pip/zipapp/
../
pip-22.3.1.pyz 06-Feb-2026 03:13 2027028
pip-22.3.pyz 06-Feb-2026 03:13 2027025
pip-23.0.1.pyz 06-Feb-2026 03:13 2030798
...
pip-26.0.1.pyz 06-Feb-2026 03:13 1729787
pip-26.0.pyz 06-Feb-2026 03:13 1729739
aaa@kylin-pc:~/par$ curl -LO https://bootstrap.pypa.io/pip/zipapp/pip-22.3.1.pyz -C -
** Resuming transfer from byte position 577536
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1415k 100 1415k 0 0 21992 0 0:01:05 0:01:05 --:--:-- 39288
用旧版pip.pyz列出已安装的包
aaa@kylin-pc:~/par$ python3 pip-22.3.1.pyz list installed
Package Version
------------------- -------------
APScheduler 0.0.0
argh 0.26.2
blinker 1.4
certifi 2019.11.28
cffi 1.14.0
...
watchdog 0.9.0
websocket-client 0.53.0
aaa@kylin-pc:~/par$
编辑pip配置文件
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
或者在命令行中指定阿里云镜像,注意限定要安装的版本,以免python 3.8不支持。
aaa@kylin-pc:~/par$ python3 pip-22.3.1.pyz install "numpy>=1.21,<1.22" "pandas>=1.3,<1.4" "matplotlib>=3.5,<3.6" -i https://mirrors.aliyun.com/pypi/simple/
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting numpy<1.22,>=1.21
Downloading https://mirrors.aliyun.com/pypi/packages/86/c7/3f68d0a8dcc9458879c614707e6ffaf64a108664cfbba9702d3ba7ca4c82/numpy-1.21.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.0/13.0 MB 2.4 MB/s eta 0:00:00
Collecting pandas<1.4,>=1.3
Downloading https://mirrors.aliyun.com/pypi/packages/79/f3/d6ccc0699c540c0f9f6302a553eea1efd9133f2c2a746987a96bcc22c253/pandas-1.3.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.9/10.9 MB 2.4 MB/s eta 0:00:00
Collecting matplotlib<3.6,>=3.5
Downloading https://mirrors.aliyun.com/pypi/packages/69/2a/6cf748ea590bcdc8a35fc9eff57505cae78f4c15035010c10cbe8bb3fae9/matplotlib-3.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.7/11.7 MB 2.3 MB/s eta 0:00:00
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/lib/python3/dist-packages (from pandas<1.4,>=1.3) (2.7.3)
Requirement already satisfied: pytz>=2017.3 in /usr/lib/python3/dist-packages (from pandas<1.4,>=1.3) (2019.3)
Collecting cycler>=0.10
Downloading https://mirrors.aliyun.com/pypi/packages/e7/05/c19819d5e3d95294a6f5947fb9b9629efb316b96de511b418c53d245aae6/cycler-0.12.1-py3-none-any.whl (8.3 kB)
Collecting pyparsing>=2.2.1
Downloading https://mirrors.aliyun.com/pypi/packages/e5/0c/0e3c05b1c87bb6a1c76d281b0f35e78d2d80ac91b5f8f524cebf77f51049/pyparsing-3.1.4-py3-none-any.whl (104 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.1/104.1 kB 20.1 MB/s eta 0:00:00
Collecting packaging>=20.0
Downloading https://mirrors.aliyun.com/pypi/packages/b7/b9/c538f279a4e237a006a2c98387d081e9eb060d203d8ed34467cc0f0b9b53/packaging-26.0-py3-none-any.whl (74 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 74.4/74.4 kB 10.8 MB/s eta 0:00:00
Collecting fonttools>=4.22.0
Downloading https://mirrors.aliyun.com/pypi/packages/17/b2/4e887b674938b4c3848029a4134ac90dd8653ea80b4f464fa1edeae37f25/fonttools-4.57.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.6/4.6 MB 3.5 MB/s eta 0:00:00
Collecting kiwisolver>=1.0.1
Downloading https://mirrors.aliyun.com/pypi/packages/54/a4/3b5a2542429e182a4df0528214e76803f79d016110f5e67c414a0357cd7d/kiwisolver-1.4.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 3.2 MB/s eta 0:00:00
Requirement already satisfied: pillow>=6.2.0 in /usr/lib/python3/dist-packages (from matplotlib<3.6,>=3.5) (7.0.0)
Installing collected packages: pyparsing, packaging, numpy, kiwisolver, fonttools, cycler, pandas, matplotlib
WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/home/aaa/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts fonttools, pyftmerge, pyftsubset and ttx are installed in '/home/aaa/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed cycler-0.12.1 fonttools-4.57.0 kiwisolver-1.4.7 matplotlib-3.5.3 numpy-1.21.6 packaging-26.0 pandas-1.3.5 pyparsing-3.1.4
安装完,pandas、numpy和matplotlib都可以导入使用了。
aaa@kylin-pc:~/par$ python3
Python 3.8.10 (default, Feb 20 2025, 02:54:46)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> print(pd.__version__)
1.3.5
>>>
>>> data = {'Name': ['Google', 'Runoob', 'Taobao'], 'Age': [25, 30, 35]}
>>> df = pd.DataFrame(data)
>>> print(df)
Name Age
0 Google 25
1 Runoob 30
2 Taobao 35
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>>
>>> xpoints = np.array([0, 6])
>>> ypoints = np.array([0, 100])
>>>
>>> plt.plot(xpoints, ypoints)
[<matplotlib.lines.Line2D object at 0x7f7155be20>]
>>> plt.show()
更多推荐


所有评论(0)