linux :ubuntu 终端输入pip/pip3没有反应

本文介绍了如何解决Ubuntu终端中pip和pip3命令无响应的问题。首先通过`which`命令找到它们的安装路径,然后删除现有版本,接着使用`apt-get install python3-pip`重新安装pip3,最后更新pip到最新版本以消除警告。

问题:ubuntu 终端输入pip/pip3没有反应

解决方案

  • 1、查到到pip和pip3在电脑上的位置
which pip
# /home/sunzl/.local/bin/pip

which pip3
# /home/sunzl/.local/bin/pip3
  • 2、删除电脑上的pip和pip3
例如:
rm /home/sunzl/.local/bin/pip
rm /home/sunzl/.local/bin/pip3
  • 3、重新安装pip3
apt-get install python3-pip
  • 4、解决告警:DEPRECATION: 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.
python3 -m pip install --upgrade pip # 更新到最新版本
版权所有 (C) Microsoft Corporation。保留所有权利。 尝试新的跨平台 PowerShell https://aka.ms/pscore6 (.venv1) PS D:\PythonProject> buildozer -v android debug # Check configuration tokens Unknown command/target android (.venv1) PS D:\PythonProject> pip show buildozer Name: buildozer Version: 1.5.0 Summary: Generic Python packager for Android / iOS and Desktop Home-page: https://github.com/kivy/buildozer Author-email: mat@kivy.org License: MIT Location: d:\pythonproject\.venv1\lib\site-packages Requires: pexpect, sh, virtualenv Required-by: (.venv1) PS D:\PythonProject> pip show python-for-android Name: python-for-android Version: 2024.1.21 Summary: A development tool that packages Python apps into binaries that can run on Android devices. Home-page: https://github.com/kivy/python-for-android Author: Kivy Team and other contributors Author-email: kivy-dev@googlegroups.com License: MIT Location: d:\pythonproject\.venv1\lib\site-packages Requires: appdirs, build, colorama, jinja2, packaging, setuptools, toml Required-by: (.venv1) PS D:\PythonProject> wsl 适用于 Linux 的 Windows 子系统现已在 Microsoft Store 中可用! 你可以通过运行“wsl.exe --update”或通过访问 https://aka.ms/wslstorepage 进行升级 从 Microsoft Store 安装 WSL 将可以更快地获取最新的 WSL 更新。 有关详细信息,请访问 https://aka.ms/wslstoreinfo Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro System information as of Tue Sep 2 14:07:45 CST 2025 System load: 0.52 Processes: 8 Usage of /home: unknown Users logged in: 0 Memory usage: 69% IPv4 address for wifi0: 11.1.1.211 Swap usage: 3% This message is shown once a day. To disable it please create the /home/aac414/.hushlogin file. aac414@DESKTOP-AORSPFA:/mnt/d/PythonProject$ sudo apt update sudo apt install -y python3-pip python3-setuptools git pip3 install buildozer python-for-android [sudo] password for aac414: Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease Get:2 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB] Get:3 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB] Get:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB] Get:5 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1385 kB] Get:6 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [1106 kB] Get:7 http://archive.ubuntu.com/ubuntu noble-updates/main Translation-en [273 kB] Get:8 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [175 kB] Get:9 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 c-n-f Metadata [14.9 kB] Get:10 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1471 kB] Get:11 http://archive.ubuntu.com/ubuntu noble-updates/universe Translation-en [297 kB] Get:12 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [377 kB] Get:13 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 c-n-f Metadata [30.5 kB] Get:14 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [1785 kB] Get:15 http://archive.ubuntu.com/ubuntu noble-updates/restricted Translation-en [399 kB] Get:16 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Components [212 B] Get:17 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B] Get:18 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [7084 B] Get:19 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [30.2 kB] Get:20 http://archive.ubuntu.com/ubuntu noble-backports/universe Translation-en [17.4 kB] Get:21 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [19.2 kB] Get:22 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [216 B] Get:23 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B] Get:24 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [190 kB] Get:25 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [21.6 kB] Get:26 http://security.ubuntu.com/ubuntu noble-security/main amd64 c-n-f Metadata [8708 B] Get:27 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [881 kB] Get:28 http://security.ubuntu.com/ubuntu noble-security/universe Translation-en [195 kB] Get:29 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [52.3 kB] Get:30 http://security.ubuntu.com/ubuntu noble-security/universe amd64 c-n-f Metadata [18.0 kB] Get:31 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [1685 kB] Get:32 http://security.ubuntu.com/ubuntu noble-security/restricted Translation-en [377 kB] Get:33 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Components [212 B] Get:34 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [212 B] Fetched 11.2 MB in 7s (1703 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 159 packages can be upgraded. Run 'apt list --upgradable' to see them. Reading package lists... Done Building dependency tree... Done Reading state information... Done You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: python3-pip : Depends: python3-wheel but it is not going to be installed Recommends: build-essential but it is not going to be installed Recommends: python3-dev (>= 3.2) but it is not going to be installed python3-setuptools : Depends: python3-pkg-resources (= 68.1.2-2ubuntu1.2) but 68.1.2-2ubuntu1.1 is to be installed systemd-sysv : Depends: systemd (= 255.4-1ubuntu8.4) but 255.4-1ubuntu8.10 is to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). Command 'pip3' not found, but can be installed with: sudo apt install python3-pip aac414@DESKTOP-AORSPFA:/mnt/d/PythonProject$ cd /mnt/d/PythonProject buildozer init buildozer: command not found aac414@DESKTOP-AORSPFA:/mnt/d/PythonProject$ 好像报错了吗?
最新发布
09-03
你的问题非常清晰,现在我们一步一步来分析和解决你遇到的错误。 --- ## ❗你遇到的问题 你在 **WSL2 终端中运行以下命令时遇到错误**: ```bash sudo apt update sudo apt install -y python3-pip python3-setuptools git pip3 install buildozer python-for-android ``` 但出现了两个关键错误: 1. `Command 'pip3' not found` 2. `buildozer: command not found` --- ## ✅ 问题分析与解决 ### ❌ 错误 1:`Command 'pip3' not found` 这意味着你虽然尝试安装了 `python3-pip`,但由于依赖问题没有成功安装。 ```bash E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). ``` 这说明系统中存在依赖冲突,需要先修复。 --- ### ✅ 解决方法 1:修复依赖并安装 pip3 在 WSL2 的终端中依次运行: ```bash sudo apt --fix-broken install sudo apt install -y python3-pip python3-setuptools git ``` 此时你应该可以使用 `pip3` 命令了。 验证: ```bash pip3 --version ``` --- ### ❌ 错误 2:`buildozer: command not found` 即使你运行了: ```bash pip3 install buildozer python-for-android ``` 可能仍然无法找到 `buildozer` 命令。 原因可能是: - `buildozer` 没有被安装成功 - 安装路径未加入环境变量 --- ### ✅ 解决方法 2:确保 buildozer 正确安装 重新安装: ```bash pip3 install --no-cache-dir buildozer python-for-android ``` 然后验证是否安装成功: ```bash buildozer --version ``` 如果仍然提示找不到命令,说明它被安装到了用户目录下的 `.local/bin` 中,你需要将它加入环境变量: ```bash export PATH=$PATH:~/.local/bin ``` 你可以将上面这行添加到 `~/.bashrc` 文件中,使其永久生效: ```bash echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc source ~/.bashrc ``` 再次验证: ```bash buildozer --version ``` --- ### ✅ 最终正确流程(在 WSL2 终端中运行) ```bash # 更新包列表并修复依赖 sudo apt update sudo apt --fix-broken install # 安装必要依赖 sudo apt install -y python3-pip python3-setuptools git # 安装 Buildozer 和 python-for-android pip3 install --no-cache-dir buildozer python-for-android # 添加 buildozer 到 PATH(如果找不到命令) echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc source ~/.bashrc # 验证安装 buildozer --version # 初始化项目 cd /mnt/d/PythonProject buildozer init # 打包 Android APK buildozer -v android debug ``` --- ## ✅ 总结 | 问题 | 原因 | 解决方法 | |------|------|----------| | `pip3 not found` | 依赖冲突导致未安装成功 | 使用 `apt --fix-broken install` 修复 | | `buildozer: command not found` | 未加入 PATH 或安装失败 | 使用 `export PATH` 并重新安装 | | Buildozer 在 Windows 原生终端无法运行 | 不支持 Windows | 使用 WSL2 或 Docker | | Buildozer 提示 “Unknown command/target android” | Windows 环境不兼容 | 必须在 WSL2 中运行 | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值