安装常见python包,出现的问题,及其解决的办法

1、安装pandas

sudo apt-get install python-pip
sudo pip install numpy
sudo pip install pandas
在安装numpy时,会需要安装python-dev,出现如下错误,依赖关系不满足。

The following packages have unmet dependencies: python2.7-dev : 

Depends:python2.7 (= 2.7.3-0ubuntu3) but 2.7.3-0ubuntu3.1 is to be installed 

Depends: libpython2.7 (= 2.7.3-0ubuntu3) but 2.7.3-0ubuntu3.1 is to be installed E: Unable to correct problems, you have held broken packages.

解决办法:http://qnundrum.com/question/431114。

sudo aptitude install python-dev
sudo apt-get install python-dev

上述安装后还是会有问题,因为pip安装pandas时,默认安装的是基于python2的pandas。

而,我的脚本使用的是python3,就会报错。

---------------------------------------------------------------------------------------------------------------------

Traceback (most recent call last):
  File "./util/count_feat.py", line 3, in
    import pandas as pd
ImportError: No module named 'pandas'

count_feat.py的内容:

#!/usr/bin/env python3
import argparse
import pandas as pd
import pickle

-----------------------------------------

ImportError的原因是:没有安装,python3对应的pandas.

解决方案:

http://stackoverflow.com/questions/18926696/python3-and-pandas

http://stackoverflow.com/questions/25172981/pandas-and-python3-4-co-existing-with-python-2-7

http://www.kissthink.com/archive/--4886.html

总结起来:

1、先装pip3:pip3是为python3安装模块的工具。

sudo apt-get install python3-setuptools

        sudo easy_install3 pip

2、安装python3的环境

sudo apt-get install  python3-dev

3、 安装python3的panda

pip3 install pandas

安装常见python包,出现的问题,及其解决的办法_第1张图片

安装成功后,python2和python3都有对应的panda.

---------------------------------------------------------------------------------------------------------------------

/usr/local/lib目录下,存放着各种安装的包。


/usr/local/lib/python2.7/dist-packages目录下存放着,为python2.7安装的包:


/usr/local/lib/python3.2/dist-packages目录下,存放着为python3.2安装的包:


/usr/local/lib/python2.7/dist-packages 和 /usr/local/lib/python3.2/dist-packages都有numpy,pandas,说明了对于pandas等包对于python2.7和python3.2等都要单独安装,python2.7和python3.2看出是不同的软件。

各种安装资源列表:

https://www.python.org/ftp/python/

安装常见python包,出现的问题,及其解决的办法_第2张图片

你可能感兴趣的:(Python,基础,python,安装)