将Pandas引入Python

2024-04-26 11:36:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚刚安装了Python3.5.2。我在shell/IDLE环境中工作,试图导入熊猫。

但是当我写:导入熊猫

我得到以下信息:

Traceback (most recent call last):
  File "C:/Users/bartogre/Desktop/Program1.py", line 1, in <module>
    import pandas
ImportError: No module named 'pandas'

如何将任何模块添加到Python 3.5.2正在读取的库中?我不想在水蟒公司工作。

我看了这个视频:https://www.youtube.com/watch?v=ddpYVA-7wq4

下面是我从CMD得到的输出:

C:\Users\bartogre>
C:\Users\bartogre>cd c:\users\bartogre\desktop\pyodbc-master
c:\Users\bartogre\Desktop\pyodbc-master>python setup.py
c:\Users\bartogre\Desktop\pyodbc-master>python setup.py install

'git' is not recognized as an internal or external command,
operable program or batch file.
WARNING: git describe failed with: 1
WARNING: Unable to determine version.  Using 3.0.0.0
C:\Program Files (x86)\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\s
etuptools\dist.py:340: UserWarning: The version specified ('3.0.0-unsupported')
is an invalid version, this may not work as expected with newer versions of setu
ptools, pip, and PyPI. Please see PEP 440 for more details.
running install
running bdist_egg
running egg_info
writing pyodbc.egg-info\PKG-INFO
writing dependency_links to pyodbc.egg-info\dependency_links.txt
writing top-level names to pyodbc.egg-info\top_level.txt
reading manifest file 'pyodbc.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyodbc.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
building 'pyodbc' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++
Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Tags: installtopyinfomastertxtisegg
2条回答

这是所有伟大的反馈-我通过康达安装。而且,我在ILDE环境中使用Spyder。请从下面的命令。

Microsoft Windows[版本6.1.7601] 版权所有(c)2009 Microsoft Corporation。保留所有权利。

C:\ Windows\system32>;conda安装pyodbc 使用Anaconda云api站点https://api.anaconda.org 正在获取包元数据:。。。。 解决包规格:。。。。。。。。。

在环境C:\用户\哈尔\水蟒3中安装的程序包计划:

将下载以下软件包:

package                    |            build
---------------------------|-----------------
conda-env-2.6.0            |                0          498 B
python-3.5.2               |                0        30.3 MB
pyodbc-3.0.10              |           py35_1          48 KB
ruamel_yaml-0.11.14        |           py35_0         217 KB
conda-4.2.9                |           py35_0         428 KB
------------------------------------------------------------
                                       Total:        31.0 MB

将安装以下新软件包:

pyodbc:      3.0.10-py35_1
ruamel_yaml: 0.11.14-py35_0

将更新以下程序包:

conda:       4.0.5-py35_0 --> 4.2.9-py35_0
conda-env:   2.4.5-py35_0 --> 2.6.0-0
python:      3.5.1-4      --> 3.5.2-0

继续([y]/n)?是的

正在获取包。。。 条件-env-2.6。时间:0:00:00 0.00 B/s 时间:0:00:20 1.56 MB/s 时间:0:00:00 788.82 kB/s 鲁阿梅尔阿穆亚姆-0。时间:0:00:00 837.06 kB/s 时间:0:00:00 969.21 kB/s 正在提取包。。。 ####################################### 正在取消链接包。。。 ####################################### 正在链接包。。。 #######################################

C:\ Windows\system32>

一点背景知识:一个系统可以有多个Python安装。在Windows上,每个目录都有python.exe和Lib/site packages/。要将包与特定的python.exe一起使用,必须安装到相应的站点包中。

在您的例子中,“python”调用“C:\程序文件(x86)\ Anaconda3\python.exe”。是否有其他要使用的python安装?

无论如何,当前在Windows上安装软件包的标准方法是使用pip。在控制台中运行它的最佳方法是

some/path> <some python> -m pip install package 

其中<some python>python来调用默认安装,或者是其他东西来获取另一个安装。Pip首先去pypi.python.org找到这个包。如果包包含C代码,它可能会找到合适的预构建二进制或尝试在本地编译,这需要Visual C++编译器的正确版本。

如果pip没有为您的安装找到预构建的二进制文件,我将执行以下操作。对于大约200个包,可以在http://www.lfd.uci.edu/~gohlke/pythonlibs/找到非官方的二进制文件。这个网站已经上线了至少十年,我和其他很多人都在使用它。Cristoph给出了如何下载文件并使用pip安装它的说明。

相关问题 更多 >