Python 导入错误:没有名为 Pandas 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33481974/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:25:47  来源:igfitidea点击:

ImportError: No module named pandas

pythonpandas

提问by Sangram Barge

I am trying to write a code in python to fetch twitter data i am not getting error for twython. But i am getting error for pandas.

我正在尝试用 python 编写代码来获取 twitter 数据我没有收到 twython 的错误。但是我遇到了熊猫的错误​​。

I have installed pandas using pip install pandas. But i still get this error . Please help

我已经使用 pip install pandas 安装了熊猫。但我仍然收到此错误。请帮忙

F:\>pip install pandas
Collecting pandas
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
:90: InsecurePlatformWarning: A true SSLContext object is not available. This pr
events urllib3 from configuring SSL appropriately and may cause certain SSL conn
ections to fail. For more information, see https://urllib3.readthedocs.org/en/la
test/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached pandas-0.17.0-cp27-none-win32.whl
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in c:\pyth
on27\lib\site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in c:\
python27\lib\site-packages (from pandas)
Collecting numpy>=1.7.0 (from pandas)
  Downloading numpy-1.10.1.tar.gz (4.0MB)
    100% |################################| 4.1MB 26kB/s
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in c:\python2
7\lib\site-packages (from python-dateutil->pandas)
Building wheels for collected packages: numpy
  Running setup.py bdist_wheel for numpy
  Complete output from command c:\python27\python.exe -c "import setuptools;__fi
le__='c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\setup.p
y';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
 bdist_wheel -d c:\users\sangram\appdata\local\temp\tmppmwkw4pip-wheel-:
  Running from numpy source directory.
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for numpy
Failed to build numpy
Installing collected packages: numpy, pandas
  Running setup.py install for numpy
    Complete output from command c:\python27\python.exe -c "import setuptools, t
okenize;__file__='c:\users\sangram\appdata\local\temp\pip-build-m6knxg\nu
mpy\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().rep
lace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\sangram\appdat
a\local\temp\pip-ll4zaf-record\install-record.txt --single-version-externally-ma
naged --compile:
    blas_opt_info:
    blas_mkl_info:
      libraries mkl,vml,guide not found in ['c:\python27\lib', 'C:\', 'c:\py
thon27\libs']
      NOT AVAILABLE

    openblas_info:
      libraries openblas not found in ['c:\python27\lib', 'C:\', 'c:\python2
7\libs']
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['c:\python27\lib', 'C:\', 'c:\python27\
\libs']
      NOT AVAILABLE

    atlas_3_10_blas_info:
      libraries satlas not found in ['c:\python27\lib', 'C:\', 'c:\python27\
\libs']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['c:\python27\lib', 'C:\
', 'c:\python27\libs']
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['c:\python27\lib', 'C:\', '
c:\python27\libs']
      NOT AVAILABLE

    blas_info:
      libraries blas not found in ['c:\python27\lib', 'C:\', 'c:\python27\l
ibs']
      NOT AVAILABLE

    blas_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    non-existing path in 'numpy\distutils': 'site.cfg'
    F2PY Version 2
    lapack_opt_info:
    openblas_lapack_info:
      libraries openblas not found in ['c:\python27\lib', 'C:\', 'c:\python2
7\libs']
      NOT AVAILABLE

    lapack_mkl_info:
    mkl_info:
      libraries mkl,vml,guide not found in ['c:\python27\lib', 'C:\', 'c:\py
thon27\libs']
      NOT AVAILABLE

      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas,tatlas not found in c:\python27\lib
      libraries lapack_atlas not found in c:\python27\lib
      libraries tatlas,tatlas not found in C:\
      libraries lapack_atlas not found in C:\
      libraries tatlas,tatlas not found in c:\python27\libs
      libraries lapack_atlas not found in c:\python27\libs
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries satlas,satlas not found in c:\python27\lib
      libraries lapack_atlas not found in c:\python27\lib
      libraries satlas,satlas not found in C:\
      libraries lapack_atlas not found in C:\
      libraries satlas,satlas not found in c:\python27\libs
      libraries lapack_atlas not found in c:\python27\libs
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in c:\python27\lib
      libraries lapack_atlas not found in c:\python27\lib
      libraries ptf77blas,ptcblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
      libraries ptf77blas,ptcblas,atlas not found in c:\python27\libs
      libraries lapack_atlas not found in c:\python27\libs
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries f77blas,cblas,atlas not found in c:\python27\lib
      libraries lapack_atlas not found in c:\python27\lib
      libraries f77blas,cblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
      libraries f77blas,cblas,atlas not found in c:\python27\libs
      libraries lapack_atlas not found in c:\python27\libs
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['c:\python27\lib', 'C:\', 'c:\python27\
\libs']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    running install
    running build
    running config_cc
    unifing config_cc, config, build_clib, build_ext, build commands --compiler
options
    running config_fc
    unifing config_fc, config, build_clib, build_ext, build commands --fcompiler
 options
    running build_src
    build_src
    building py_modules sources
    creating build
    creating build\src.win32-2.7
    creating build\src.win32-2.7\numpy
    creating build\src.win32-2.7\numpy\distutils
    building library "npymath" sources
    Running from numpy source directory.
    c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\numpy\distutils\s
ystem_info.py:1651: UserWarning:
        Atlas (http://math-atlas.sourceforge.net/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [atlas]) or by setting
        the ATLAS environment variable.
      warnings.warn(AtlasNotFoundError.__doc__)
    c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\numpy\distutils\s
ystem_info.py:1660: UserWarning:
        Blas (http://www.netlib.org/blas/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [blas]) or by setting
        the BLAS environment variable.
      warnings.warn(BlasNotFoundError.__doc__)
    c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\numpy\distutils\s
ystem_info.py:1663: UserWarning:
        Blas (http://www.netlib.org/blas/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [blas_src]) or by setting
        the BLAS_SRC environment variable.
      warnings.warn(BlasSrcNotFoundError.__doc__)
    c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\numpy\distutils\s
ystem_info.py:1552: UserWarning:
        Atlas (http://math-atlas.sourceforge.net/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [atlas]) or by setting
        the ATLAS environment variable.
      warnings.warn(AtlasNotFoundError.__doc__)
    c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\numpy\distutils\s
ystem_info.py:1563: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      warnings.warn(LapackNotFoundError.__doc__)
    c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy\numpy\distutils\s
ystem_info.py:1566: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      warnings.warn(LapackSrcNotFoundError.__doc__)
    c:\python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution opt
ion: 'define_macros'
      warnings.warn(msg)
    error: Unable to find vcvarsall.bat

    ----------------------------------------
Command "c:\python27\python.exe -c "import setuptools, tokenize;__file__='c:\us
ers\sangram\appdata\local\temp\pip-build-m6knxg\numpy\setup.py';exec(comp
ile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __fi
le__, 'exec'))" install --record c:\users\sangram\appdata\local\temp\pip-ll4zaf-
record\install-record.txt --single-version-externally-managed --compile" failed
with error code 1 in c:\users\sangram\appdata\local\temp\pip-build-m6knxg\numpy

F:\>python tweet_fetcher.py
Traceback (most recent call last):
  File "tweet_fetcher.py", line 1, in <module>
    import pandas
ImportError: No module named pandas

回答by TkTech

You're missing a few (not terribly clear) steps. Pandas is distributed through pip as a wheel, which means you need to do:

你错过了几个(不是很清楚)步骤。Pandas 通过 pip 作为wheel分发,这意味着您需要执行以下操作:

pip install wheel
pip install pandas

You're probably going to run into other issues after this - it looks like you're installing on Windows which isn't the most friendly of targets for numpy/scipy/pandas. Alternatively, you could pickup a binary installer from here.

在此之后,您可能会遇到其他问题 - 看起来您正在 Windows 上安装,这不是 numpy/scipy/pandas 最友好的目标。或者,您可以从这里选择一个二进制安装程序。

You also had an error installing numpy. Like before, I recommend grabbing a binary installerfor this, as it's not a simple process. However, you can resolve your current error by installing this packagefrom Microsoft.

您在安装 numpy 时也遇到了错误。像以前一样,我建议为此使用二进制安装程序,因为这不是一个简单的过程。但是,您可以通过从 Microsoft安装此软件包来解决当前的错误。

While it's completely possible to get a perfect environment setup on Windows, I have found the quality-of-life for a Python dev is vastly improved by setting up a debian VM. Especially with the scientific packages, you will run into many cases like this.

虽然完全有可能在 Windows 上获得完美的环境设置,但我发现通过设置 debian VM 极大地提高了 Python 开发人员的生活质量。特别是使用科学包,你会遇到很多这样的情况。

回答by Rockie Yang

When I try to build docker image zeppelin-highcharts, I find that the base image openjdk:8 also does not have pandas installed. I solved it with this steps.

当我尝试构建docker镜像zeppelin-highcharts 时,我发现基础镜像 openjdk:8 也没有安装 pandas。我用这个步骤解决了它。

curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | python
pip install pandas

I refered what-is-the-official-preferred-way-to-install-pip-and-virtualenv-systemwide

我指的是 what-the-the-official-preferred-way-to-install-pip-and-virtualenv-systemwide

回答by Ramy M. Mousa

It might be too late to answer this but I just had the problem and I kept installing and uninstalling, it turns out the the problem happens when you're installing pandasto a version of pythonand trying to run the program using another python version

这可能是来不及回答这个问题,但我只是有这个问题,我不停的安装和卸载,原来的问题发生在你正在安装pandas一个版本的python,并尝试运行使用其他程序python version

So to start off, run:

所以要开始,运行:

which python
python --version
which pip

make sure both are aligned, most probably, python is 2.7and pip is working on 3.xor pip is coming from anaconda's python version which is highly likely to be 3.xas well

确保两者都对齐,最有可能的是,python 是2.7并且 pip 正在处理3.x或 pip 来自 anaconda 的 python 版本,这很可能3.x也是如此

Incase of pythonredirects to 2.7, and pip redirects to pip3, install pandas using pip install pandasand use python3 file_name.pyto run the program.

如果python重定向到 2.7,而 pip 重定向到 pip3,请安装 pandas usingpip install pandas和 usepython3 file_name.py来运行程序。

回答by Sinh Nguy?n ??c

I fixed the same problem with the below commands... Type python on your terminal. If you see python version 2.x then run these two commands to install pandas: sudo python -m pip install wheel and sudo python -m pip install pandas. Else if you see python version 3.x then run these two commands to install pandas: sudo python3 -m pip install wheel and sudo python3 -m pip install pandas. Good Luck!

我用下面的命令解决了同样的问题......在你的终端上输入 python 。如果您看到 python 版本 2.x,请运行以下两个命令来安装 pandas:sudo python -m pip install wheel 和 sudo python -m pip install pandas。否则,如果您看到 python 版本 3.x,则运行以下两个命令来安装 Pandas:sudo python3 -m pip install wheel 和 sudo python3 -m pip install pandas。祝你好运!