橙色3:ImportError:无法导入名称'_variable'

Posted

技术标签:

【中文标题】橙色3:ImportError:无法导入名称\'_variable\'【英文标题】:orange3: ImportError: cannot import name '_variable'橙色3:ImportError:无法导入名称'_variable' 【发布时间】:2016-12-28 21:33:56 【问题描述】:

我正在尝试在我的 Mac 上使用 Orange3,但出现此错误:ImportError: cannot import name '_variable'

这是我的设置:

$ cd orange_playground
$ virtualenv -p python3 venv
$ pip install orange3
$ source venv/bin/activate
$ python

输出如下:

Python 3.4.2 (default, Oct  8 2014, 19:29:52)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Orange
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "orange_playground/venv/lib/python3.4/site-packages/Orange/__init__.py", line 11, in <module>
    from .misc.lazy_module import _LazyModule
  File "orange_playground/venv/lib/python3.4/site-packages/Orange/misc/__init__.py", line 3, in <module>
    from .distmatrix import DistMatrix
  File "orange_playground/venv/lib/python3.4/site-packages/Orange/misc/distmatrix.py", line 3, in <module>
    from Orange.data import Table, StringVariable, Domain
  File "orange_playground/venv/lib/python3.4/site-packages/Orange/data/__init__.py", line 4, in <module>
    from .variable import *
  File "orange_playground/venv/lib/python3.4/site-packages/Orange/data/variable.py", line 11, in <module>
    from Orange.data import _variable
ImportError: cannot import name '_variable'

来自orange_playground/venv/lib/python3.4/site-packages/Orange/data/variable.py的第一行代码:

import collections
import re

from datetime import datetime, timedelta, timezone
from numbers import Number, Real, Integral
from math import isnan, floor
from pickle import PickleError

import numpy as np

from Orange.data import _variable
from Orange.util import Registry, color_to_hex, hex_to_color

__all__ = ["Unknown", "MISSING_VALUES", "make_variable", "is_discrete_values",
           "Value", "Variable", "ContinuousVariable", "DiscreteVariable",
           "StringVariable", "TimeVariable"]


# For storing unknowns
Unknown = ValueUnknown = float("nan")
# For checking for unknowns
MISSING_VALUES = np.nan, "?", "nan", ".", "", "NA", "~", None

...

有什么想法吗?

【问题讨论】:

_variable 是一个compiled module。你是怎么安装的? pip install orange3 在 Mac 上的 venv 有错误输出吗?你有cython installed吗?您是否安装了 XCode (check if the command line tools are installed)? 啊,还有一些要求,见orange3 wiki。 @MartijnPieters 有效。谢谢!!! 【参考方案1】:

Installing Orange3 from sourcelike @MartijnPieters 推荐作品!谢谢。

【讨论】:

以上是关于橙色3:ImportError:无法导入名称'_variable'的主要内容,如果未能解决你的问题,请参考以下文章

ImportError:无法使用 Flask 导入名称“app”

ImportError:无法导入名称 _imaging

Python 3 ImportError:无法导入名称“模型选择”OS X 10.11.3,Anaconda

ImportError:无法导入名称 _UNPACK_INT

ImportError:无法导入名称“_validate_lengths”

ImportError:从 sklearn 导入 TfidfVectorizer 时无法导入名称 __check_build