pandas - 我想在 JUPYTER 中使用 pandas2ri 但出现 tzlocal 问题?
问题描述
每次我尝试在 jupyter 中导入 pandas2ri,python 界面:
from rpy2.robjects import pandas2ri
我收到以下错误:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-28-cc52694d111a> in <module>()
----> 1 from rpy2.robjects import pandas2ri
/Users/sondosayyash/anaconda/lib/python3.6/site-packages/rpy2/robjects/pandas2ri.py in <module>()
21 import numpy
22 import pytz
---> 23 import tzlocal
24 import warnings
25
ModuleNotFoundError: No module named 'tzlocal'
我试着用
from dateutil.tz import tzlocal
但这似乎并没有解决问题。
我已经安装了 tzlocal,它在我的电脑上。当我在ipython上导入pandas2ri时没有问题..只有在jupyter环境中调用时才会出现问题。
这是我尝试再次安装 tzlocal 时收到的消息:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: tzlocal in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.5.1)
Requirement already satisfied: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from tzlocal) (2017.2)
解决方案
在 Jupyter 中运行 rpy2 时,我遇到了类似的问题。我之前没有安装该软件包。我刚刚安装了软件包,错误就消失了。您可以尝试再次安装该软件包,看看它是否有助于解决您的问题。
pip install tzlocal
我必须补充一点,我使用的是 Python 3.6.8 而不是 2.7
推荐阅读
- c++ - 带 SetRange 的 S3Client::GetObject 返回错误数据?
- load-testing - 如何在加特林中设置减速时间?
- ios - 我的 viewcontroller 不属于 viewdidLoad 方法
- python - SQLAlchemy drop_all 不删除表
- .htaccess - 重定向“/*”但排除“/myfolder/*”
- php - 一个带有某些索引值的 php 数组
- php - 允许在网站上播放 mp3 文件,但禁止从直接链接下载
- javascript - ParcelJs 在所有文件链接之前添加额外的“/”
- r - R - 分组并为分组结果创建新列
- python-3.x - 无法迭代数组以平均 3 个数字组并与其他 3 个数字组进行比较