我目前正在尝试使用 Azure Jupyter Notebooks 打开镶木地板文件。我已经尝试了两个 Python 内核(2 和 3)。安装pyarrow后,我只能在 Python 内核为 2 时导入模块(不适用于 Python 3)
这是我到目前为止所做的(为了清楚起见,我没有提及我所有的各种尝试,例如使用conda代替pip,因为它也失败了):
!pip install --upgrade pip
!pip install -I Cython==0.28.5
!pip install pyarrow
import pandas
import pyarrow
import pyarrow.parquet
#so far, so good
filePath_parquet = "foo.parquet"
table_parquet_raw = pandas.read_parquet(filePath_parquet, engine='pyarrow')
如果我离线执行此操作(使用 Spyder,Python v.3.7.0),这很有效。但使用 Azure Notebook 失败。
AttributeErrorTraceback (most recent call last)
<ipython-input-54-2739da3f2d20> in <module>()
6
7 #table_parquet_raw = pd.read_parquet(filePath_parquet, engine='pyarrow')
----> 8 table_parquet_raw = pandas.read_parquet(filePath_parquet, engine='pyarrow')
AttributeError: 'module' object has no attribute 'read_parquet'
请问有什么想法吗?
先感谢您 !
编辑:
非常感谢您的回复彼得潘!我已经输入了这些语句,这是我得到的:
1.
print(pandas.__dict__)
=> read_parquet 没有出现
2.
print(pandas.__file__)
=> 我得到:
/home/nbuser/anaconda3_23/lib/python3.4/site-packages/pandas/__init__.py
导入系统;print(sys.path) => 我得到:
['', '/home/nbuser/anaconda3_23/lib/python34.zip', '/home/nbuser/anaconda3_23/lib/python3.4', '/home/nbuser/anaconda3_23/lib/python3.4/plat-linux', '/home/nbuser/anaconda3_23/lib/python3.4/lib-dynload', '/home/nbuser/.local/lib/python3.4/site-packages', '/home/nbuser/anaconda3_23/lib/python3.4/site-packages', '/home/nbuser/anaconda3_23/lib/python3.4/site-packages/Sphinx-1.3.1-py3.4.egg', '/home/nbuser/anaconda3_23/lib/python3.4/site-packages/setuptools-27.2.0-py3.4.egg', '/home/nbuser/anaconda3_23/lib/python3.4/site-packages/IPython/extensions', '/home/nbuser/.ipython']
你有什么想法吗?
编辑2:
亲爱的@PeterPan,我已经输入了两个!conda update conda
和 !conda update pandas
:当检查 Pandas 版本(pandas.__version__
)时,它仍然是0.19.2
。
我也尝试过!conda update pandas -y -f
,它返回:`Fetching package metadata .........解决包规范:。
环境/home/nbuser/anaconda3_23安装包方案:
将安装以下新软件包:
pandas: 0.19.2-np111py34_1`
打字时:
!pip install --upgrade pandas
我得到:
Requirement already up-to-date: pandas in /home/nbuser/anaconda3_23/lib/python3.4/site-packages
Requirement already up-to-date: pytz>=2011k in /home/nbuser/anaconda3_23/lib/python3.4/site-packages (from pandas)
Requirement already up-to-date: numpy>=1.9.0 in /home/nbuser/anaconda3_23/lib/python3.4/site-packages (from pandas)
Requirement already up-to-date: python-dateutil>=2 in /home/nbuser/anaconda3_23/lib/python3.4/site-packages (from pandas)
Requirement already up-to-date: six>=1.5 in /home/nbuser/anaconda3_23/lib/python3.4/site-packages (from python-dateutil>=2->pandas)
最后,输入时:
!pip install --upgrade pandas==0.24.0
我得到:
Collecting pandas==0.24.0
Could not find a version that satisfies the requirement pandas==0.24.0 (from versions: 0.1, 0.2b0, 0.2b1, 0.2, 0.3.0b0, 0.3.0b2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0rc1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0rc1, 0.8.0rc2, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0rc1, 0.19.0, 0.19.1, 0.19.2, 0.20.0rc1, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0rc1, 0.21.0, 0.21.1, 0.22.0)
No matching distribution found for pandas==0.24.0
因此,我的猜测是问题出在 Azure 中管理包的方式上。更新一个包(这里是 Pandas),应该会导致更新到可用的最新版本,不是吗?