熊猫:当我尝试使用pip安装它时出错

时间:2018-02-19 15:22:19

标签: python pandas pip

我尝试使用pip安装pandas,但会出现几个警告并出现一个错误。

这是我使用的命令

pip install pandas

我收到了几条这样的警告信息:

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/pandas/_libs/join.o -o build/lib.linux-x86_64-2.7/pandas/_libs/join.so

building 'pandas._libs.tslibs.frequencies' extension

creating build/temp.linux-x86_64-2.7/pandas/_libs/tslibs

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ipandas/_libs/src/klib -Ipandas/_libs/src -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c pandas/_libs/tslibs/frequencies.c -o build/temp.linux-x86_64-2.7/pandas/_libs/tslibs/frequencies.o -Wno-unused-function

In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1816:0,

                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,

                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,

                 from pandas/_libs/tslibs/frequencies.c:526:

/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

 #warning "Using deprecated NumPy API, disable it by " \

最后,当出现错误消息时

  Cleaning up...
  Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_flaviomb-lasse/pandas/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-O3U0h8-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_flaviomb-lasse/pandas
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
    return command.main(cmd_args)
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 37: ordinal not in range(128)`

我的python版本是Python 2.7.6,我的ubuntu版本是16.04

错误的原因是什么?

1 个答案:

答案 0 :(得分:1)

我无法重现您的错误。我使用docker来运行容器来模拟你的问题。 更具体地说,我在容器内运行docker run -it --rm ubuntu:16.04 bash

1  apt-get update
2  apt-get install wget
3  wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
4  ls
5  tar xzf Python-2.7.6.tgz
6  ls
7  cd Python-2.7.6
8  ls
9  ./configure
10  apt-get install build-essential checkinstall
11  apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
12  ./configure
13  python
14  make
15  make install
16  python
17  pip
18  curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
19  apt-get install curl
20  curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
21  ls
22  python get-pip.py
23  pip
24  pip install pandas
25  history

Pandas成功安装:

root@aa206d4f31c6:/Python-2.7.6# pip install pandas
Collecting pandas
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made,     but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS     certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://    urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is     not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer     version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading pandas-0.22.0.tar.gz (11.3MB)
    100% |################################| 11.3MB 151kB/s
Collecting python-dateutil (from pandas)
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
    100% |################################| 194kB 6.4MB/s
Collecting pytz>=2011k (from pandas)
  Downloading pytz-2018.3-py2.py3-none-any.whl (509kB)
    100% |################################| 512kB 3.0MB/s
Collecting numpy>=1.9.0 (from pandas)
  Downloading numpy-1.14.0-cp27-cp27m-manylinux1_x86_64.whl (16.9MB)
    100% |################################| 16.9MB 101kB/s
Collecting six>=1.5 (from python-dateutil->pandas)
  Downloading six-1.11.0-py2.py3-none-any.whl
Building wheels for collected packages: pandas
  Running setup.py bdist_wheel for pandas ... done
  Stored in directory: /root/.cache/pip/wheels/e8/ed/46/0596b51014f3cc49259e52dff9824e1c6fe352048a2656fc92
Successfully built pandas
Installing collected packages: six, python-dateutil, pytz, numpy, pandas
Successfully installed numpy-1.14.0 pandas-0.22.0 python-dateutil-2.6.1 pytz-2018.3 six-1.11.0

因此,您可能以不同的方式安装了系统依赖项(例如gcc),python或pip。我跟着https://askubuntu.com/questions/443048/python-2-7-6-on-ubuntu-12-04-how-to。你是怎么安装的?