Ubuntu 安装pandas
2025-08-08
计算机学习
00
请注意,本文编写于 119 天前,最后修改于 119 天前,其中某些信息可能已经过时。

记录一下安装pandas的步骤以及输出:

启动python解释器,调用系统默认Python环境

bash
展开代码
(base) cc@LAPTOP-2A2OV24P:~$ python Python 3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, 16:09:02) [GCC 11.2.0 ] on linux Type "help", "copyright", "credits" or "license" for more information. >>>

检查Python路径,显示默认Python解释器的实际路径

bash
展开代码
(base) cc@LAPTOP-2A2OV24P:~$ which python /home/cc/miniconda3/bin/python #输出

检查Conda路径,确认Conda的安装位置

bash
展开代码
(base) cc@LAPTOP-2A2OV24P:~$ which conda /home/cc/miniconda3/bin/conda

直接调用绝对路径的Python:/home/cc/miniconda3/bin/python→ 效果与步骤1相同

bash
展开代码
(base) cc@LAPTOP-2A2OV24P:~$ /home/cc/miniconda3/bin/python Python 3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, 16:09:02) [GCC 11.2.0 ] on linux Type "help", "copyright", "credits" or "license" for more information. >>>

尝试创建新Conda环境→ 准备创建名为 py310的新环境

bash
展开代码
conda create -n py310

激活py310环境,并检查python路径

bash
展开代码
conda activate py310 which python

实践:

bash
展开代码
(base) cc@LAPTOP-2A2OV24P:~$ conda activate py310 (py310) cc@LAPTOP-2A2OV24P:~$ conda env list # conda environments: # base /home/cc/miniconda3 py310 * /home/cc/miniconda3/envs/py310 (py310) cc@LAPTOP-2A2OV24P:~$ which python /home/cc/miniconda3/envs/py310/bin/python

切换回base环境,并验证python路径

bash
展开代码
conda activate base which python

实践:

bash
展开代码
```bash (py310) cc@LAPTOP-2A2OV24P:~$ conda activate base (base) cc@LAPTOP-2A2OV24P:~$ which python /home/cc/miniconda3/bin/python
  • 不同环境有独立的Python解释器路径(envs/py310/bin/vs 主bin/目录)
  • 在py310安装的包不会影响base环境

返回py310环境安装pandas

bash
展开代码
conda activate py310 pip install pandas

在特定环境下执行的命令(如pip install)仅作用于当前环境

本文作者:cc

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!