每次我尝试在 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
关于pandas - 我想在 JUPYTER 中使用 pandas2ri 但出现 tzlocal 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54676900/