pandasql will not import : ImportError: cannot import name to_sql
pandasql will not import : ImportError: cannot import name to_sql
我在 linux 命令提示符下使用 pip 安装了 pandasql,并启动了 ipython 笔记本:
felix@xanadu ~ $ sudo pip install pandasql
[sudo] password for felix:
Downloading/unpacking pandasql
Downloading pandasql-0.6.2.tar.gz
Running setup.py (path:/tmp/pip_build_root/pandasql/setup.py) egg_info for package pandasql
Installing collected packages: pandasql
Running setup.py install for pandasql
Successfully installed pandasql
Cleaning up...
felix@xanadu ~ $ ipython notebook
然后尝试在 ipython 笔记本中导入 pandas 和它:
import pandas
import pandasql
..它不开心,环顾四周但似乎没有任何地方有答案。这是它给出的错误消息:
--------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-c9fa37159ca4> in <module>()
1 import pandas
----> 2 import pandasql
/usr/local/lib/python2.7/dist-packages/pandasql/__init__.py in <module>()
----> 1 from .sqldf import sqldf
2 import os
3 import pandas as pd
4
5
/usr/local/lib/python2.7/dist-packages/pandasql/sqldf.py in <module>()
2 import pandas as pd
3 import numpy as np
----> 4 from pandas.io.sql import to_sql, read_sql
5 import re
6 import os
ImportError: cannot import name to_sql
有人有什么想法吗?干杯
你绝对应该升级到 pandas
0.16.0:
sudo pip install -U pandas
刚刚看了0.13.1 and 0.16.0中pandas/io/sql.py
的源码,to_sql()
和read_sql()
方法在旧版本中没有,虽然有在最新版本中。
在评论中总结我们的对话,为了成功构建 pandas
,您需要安装 gcc
、g++
和 python-dev
包您系统的包管理器(apt-get
、yum
、zypper
,等等)。如果您正在构建 Python 3,则需要 python3-dev
包。
如果您使用 Windows 和 Python 的标准 python.org 版本,使您的软件包保持最新的最简单方法是使用 Christoph Gohlke 的 Python Extension Packages for Windows repository. Many packages depend on his MKL-linked version of numpy
, including pandas
. The nice thing about all of these packages is that they are pre-compiled against both 32- and 64-bit versions of Python, and are generally available for Python 2.7, 3.3, and 3.4 (depending on the package, of course - some haven't been ported to Py3 yet). They are available in .whl
格式,所以 installation/upgrading 和
一样简单
pip install -U name_of_package.whl
我在 linux 命令提示符下使用 pip 安装了 pandasql,并启动了 ipython 笔记本:
felix@xanadu ~ $ sudo pip install pandasql
[sudo] password for felix:
Downloading/unpacking pandasql
Downloading pandasql-0.6.2.tar.gz
Running setup.py (path:/tmp/pip_build_root/pandasql/setup.py) egg_info for package pandasql
Installing collected packages: pandasql
Running setup.py install for pandasql
Successfully installed pandasql
Cleaning up...
felix@xanadu ~ $ ipython notebook
然后尝试在 ipython 笔记本中导入 pandas 和它:
import pandas
import pandasql
..它不开心,环顾四周但似乎没有任何地方有答案。这是它给出的错误消息:
--------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-c9fa37159ca4> in <module>()
1 import pandas
----> 2 import pandasql
/usr/local/lib/python2.7/dist-packages/pandasql/__init__.py in <module>()
----> 1 from .sqldf import sqldf
2 import os
3 import pandas as pd
4
5
/usr/local/lib/python2.7/dist-packages/pandasql/sqldf.py in <module>()
2 import pandas as pd
3 import numpy as np
----> 4 from pandas.io.sql import to_sql, read_sql
5 import re
6 import os
ImportError: cannot import name to_sql
有人有什么想法吗?干杯
你绝对应该升级到 pandas
0.16.0:
sudo pip install -U pandas
刚刚看了0.13.1 and 0.16.0中pandas/io/sql.py
的源码,to_sql()
和read_sql()
方法在旧版本中没有,虽然有在最新版本中。
在评论中总结我们的对话,为了成功构建 pandas
,您需要安装 gcc
、g++
和 python-dev
包您系统的包管理器(apt-get
、yum
、zypper
,等等)。如果您正在构建 Python 3,则需要 python3-dev
包。
如果您使用 Windows 和 Python 的标准 python.org 版本,使您的软件包保持最新的最简单方法是使用 Christoph Gohlke 的 Python Extension Packages for Windows repository. Many packages depend on his MKL-linked version of numpy
, including pandas
. The nice thing about all of these packages is that they are pre-compiled against both 32- and 64-bit versions of Python, and are generally available for Python 2.7, 3.3, and 3.4 (depending on the package, of course - some haven't been ported to Py3 yet). They are available in .whl
格式,所以 installation/upgrading 和
pip install -U name_of_package.whl