Default pip installation of Dask gives "ImportError: No module named toolz"
Default pip installation of Dask gives "ImportError: No module named toolz"
我像这样使用 pip 安装了 Dask:
pip install dask
当我尝试执行 import dask.dataframe as dd
时,我收到以下错误消息:
>>> import dask.dataframe as dd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/venv/lib/python2.7/site-packages/dask/__init__.py", line 5, in <module>
from .async import get_sync as get
File "/path/to/venv/lib/python2.7/site-packages/dask/async.py", line 120, in <module>
from toolz import identity
ImportError: No module named toolz
No module named toolz
我注意到 the documentation 状态
pip install dask
: Install only dask, which depends only on the standard library. This is appropriate if you only want the task schedulers.
所以我很困惑为什么这不起作用。
为了使用 Dask 的并行数据帧(建立在 pandas 之上),你必须告诉 pip 安装一些 "extras" (reference), as mentioned in the Dask installation documentation:
pip install "dask[dataframe]"
或者你可以这样做
pip install "dask[complete]"
获得所有技巧。 注意:您的 shell.
中可能需要也可能不需要双引号
Dask 文档中(或曾经)提到了这样做的理由:
We do this so that users of the lightweight core dask scheduler aren’t required to download the more exotic dependencies of the collections (numpy, pandas, etc.)
如 中所述,您可能希望在 virtualenv 中执行此操作,或者使用 pip install --user
将库放在您的主目录中,例如,如果您没有管理员权限对主机 OS.
的特权
额外的细节
在 Dask 0.13.0 及以下版本中,需要 toolz' identity
function within dask/async.py
. There is an open a closed pull request associated with GitHub issue #1849 删除此依赖项。 与此同时如果由于某种原因,您无法使用旧版本的 dask,您可以通过简单地执行 那个 特定问题来解决 =16=].
但这并不能(完全)解决 import dask.dataframe as dd
的问题。因为你仍然会得到 this error:
>>> import dask.dataframe as dd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/staff_agbio/PhyloWeb/data/dask-test/venv/local/lib/python2.7/site-packages/dask/dataframe/__init__.py", line 3, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/data/staff_agbio/PhyloWeb/data/dask-test/venv/local/lib/python2.7/site-packages/dask/dataframe/core.py", line 12, in <module>
import pandas as pd
ImportError: No module named pandas
或者如果您已经安装了 pandas,您将获得 ImportError: No module named cloudpickle
。因此,如果您处于这种情况,pip install "dask[dataframe]"
似乎是可行的方法。
我遇到了同样的问题,这是为我解决的问题。
- 为您的项目创建一个虚拟环境
- CD 你的项目目录(如果你擅长目录导航则不需要)
- 激活你的虚拟环境
pip install "dask[complete]"
:这将安装所有内容。您可能希望只安装给定的组件,如数据框,然后使用 pip install "dask[dataframe]"
底线是我必须在我的虚拟环境中;这只会为这个环境安装 dask。
requeriments.txt 工作:
awscli==1.16.69
botocore=1.13.0
boto3==1.9.79
numpy==1.16.2
dask[complete]
就我而言,在 windows 机器上使用 anaconda,以下是解决此问题的步骤:
- conda 安装 dask
- conda 安装 dask-core
- 安装这个基于
github评论!pip install tornado==5.0.0 distributed==2.15 dask-ml[complete]
- 重新启动我的蟒蛇。
使用下面的命令。
pip install "dask[dataframe]"
我像这样使用 pip 安装了 Dask:
pip install dask
当我尝试执行 import dask.dataframe as dd
时,我收到以下错误消息:
>>> import dask.dataframe as dd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/venv/lib/python2.7/site-packages/dask/__init__.py", line 5, in <module>
from .async import get_sync as get
File "/path/to/venv/lib/python2.7/site-packages/dask/async.py", line 120, in <module>
from toolz import identity
ImportError: No module named toolz
No module named toolz
我注意到 the documentation 状态
pip install dask
: Install only dask, which depends only on the standard library. This is appropriate if you only want the task schedulers.
所以我很困惑为什么这不起作用。
为了使用 Dask 的并行数据帧(建立在 pandas 之上),你必须告诉 pip 安装一些 "extras" (reference), as mentioned in the Dask installation documentation:
pip install "dask[dataframe]"
或者你可以这样做
pip install "dask[complete]"
获得所有技巧。 注意:您的 shell.
中可能需要也可能不需要双引号Dask 文档中(或曾经)提到了这样做的理由:
We do this so that users of the lightweight core dask scheduler aren’t required to download the more exotic dependencies of the collections (numpy, pandas, etc.)
如 pip install --user
将库放在您的主目录中,例如,如果您没有管理员权限对主机 OS.
额外的细节
在 Dask 0.13.0 及以下版本中,需要 toolz' identity
function within dask/async.py
. There is an open a closed pull request associated with GitHub issue #1849 删除此依赖项。 与此同时如果由于某种原因,您无法使用旧版本的 dask,您可以通过简单地执行 那个 特定问题来解决 =16=].
但这并不能(完全)解决 import dask.dataframe as dd
的问题。因为你仍然会得到 this error:
>>> import dask.dataframe as dd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/staff_agbio/PhyloWeb/data/dask-test/venv/local/lib/python2.7/site-packages/dask/dataframe/__init__.py", line 3, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/data/staff_agbio/PhyloWeb/data/dask-test/venv/local/lib/python2.7/site-packages/dask/dataframe/core.py", line 12, in <module>
import pandas as pd
ImportError: No module named pandas
或者如果您已经安装了 pandas,您将获得 ImportError: No module named cloudpickle
。因此,如果您处于这种情况,pip install "dask[dataframe]"
似乎是可行的方法。
我遇到了同样的问题,这是为我解决的问题。
- 为您的项目创建一个虚拟环境
- CD 你的项目目录(如果你擅长目录导航则不需要)
- 激活你的虚拟环境
pip install "dask[complete]"
:这将安装所有内容。您可能希望只安装给定的组件,如数据框,然后使用pip install "dask[dataframe]"
底线是我必须在我的虚拟环境中;这只会为这个环境安装 dask。
requeriments.txt 工作:
awscli==1.16.69
botocore=1.13.0
boto3==1.9.79
numpy==1.16.2
dask[complete]
就我而言,在 windows 机器上使用 anaconda,以下是解决此问题的步骤:
- conda 安装 dask
- conda 安装 dask-core
- 安装这个基于 github评论!pip install tornado==5.0.0 distributed==2.15 dask-ml[complete]
- 重新启动我的蟒蛇。
使用下面的命令。
pip install "dask[dataframe]"