ImportError:无法导入名称'IntEnum'

时间:2017-06-21 02:56:58

标签: python python-3.x pip packages

我正在尝试安装upstox,这是一个用于连接市场数据的Python API。我无法在Python3.5上安装它。

我的配置是 Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] on win32。我一直得到的错误是:

Collecting upstox
  Using cached upstox-0.7-py2.py3-none-any.whl
Collecting future (from upstox)
  Using cached future-0.16.0.tar.gz
Collecting websocket-client (from upstox)
  Using cached websocket_client-0.42.1-py2.py3-none-any.whl
Collecting pycurl (from upstox)
  Using cached pycurl-7.43.0-cp35-none-win32.whl
Collecting enum (from upstox)
  Using cached enum-0.4.6.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\site-packages\setuptools\__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, filterfalse, map
      File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\site-packages\setuptools\extern\__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pkg_resources\__init__.py", line 33, in <module>
        import platform
      File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\platform.py", line 117, in <module>
        import sys, os, re, subprocess
      File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 50, in <module>
        import signal
      File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\signal.py", line 4, in <module>
        from enum import IntEnum as _IntEnum
    ImportError: cannot import name 'IntEnum'

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\UserPad\AppData\Local\Temp\pycharm-packaging\enum\

4 个答案:

答案 0 :(得分:1)

pip install enum34 

将解决问题

答案 1 :(得分:0)

对于python2

sudo pip2 install -U enum

对于python3

sudo pip3 install -U enum34

答案 2 :(得分:0)

import enum import Enum
import enum import IntNum

from enum import Enum
from enum import IntEnum

class Shape (IntEnum):
    CIRCLE = 1
    SQUARE = 2


class Color (Enum):
    RED = 1
    GREEN = 2


print(Shape.CIRCLE == Color.RED)
print (Shape.CIRCLE == 1)

答案 3 :(得分:-1)

在安装所需的软件包之前,您是否安装了enum?看起来它希望你先安装它。

在CMD中运行此命令以安装enum,然后尝试安装所需的软件包:

pip install enum