问题
I am trying to install upstox, which is a Python API for connecting to market data. I am unable to install it on Python3.5.
My config is
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] on win32. And the error I keep getting is:
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\
回答1:
pip install enum34
will solve the issue
回答2:
for python2
sudo pip2 install -U enum
for python3
sudo pip3 install -U enum34
回答3:
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)
回答4:
Have you installed enum before installing your desired package? It looks like it wants you to install it first.
Run this command in CMD to install enum, and then try installing your desired package:
pip install enum
来源:https://stackoverflow.com/questions/44666136/importerror-cannot-import-name-intenum