I am attempting to download and run the FT4222 package using Python 2.7; when I try to run anything that imports from ft4222, I get this error:
Traceback (most recent call last):
File "C:\Users\...\[username]\...\FT4222.py", line 1, in <module>
import ft4222
File "C:\Python27\lib\site-packages\ft4222\__init__.py", line 16, in <module>
from .ft4222 import *
File "ft4222\ft4222.pyx", line 15, in init ft4222.ft4222
ImportError: cannot import name IntEnum
It seemed to be an issue with Enum, which I isntalled via pip install enum (also tried pip install enum34). I then get this message:
Traceback (most recent call last):
File "C:\Users\...\[username]\...\FT4222.py", line 1, in <module>
import ft4222
File "C:\Python27\lib\site-packages\ft4222\__init__.py", line 16, in <module>
from .ft4222 import *
File "ft4222\ft4222.pyx", line 16, in init ft4222.ft4222
File "C:\Python27\lib\site-packages\ft4222\GPIO\__init__.py", line 14, in <module>
from enum import IntEnum, IntFlag
ImportError: cannot import name IntFlag
FT4222 GPIO is attempting to import IntFlag from Enum, but in the C:\Python27\Lib\site-packages\enum\__init__.py
file that I have, no such thing exists:
"""Python Enumerations"""
import sys as _sys
__all__ = ['Enum', 'IntEnum', 'unique']
version = 1, 1, 10
pyver = float('%s.%s' % _sys.version_info[:2])
This is in the enum34 package. The site-packages\enum.py file doesn't have flag or intflag either (I tried uninstalling and reinstalling both, I didn't have them simultaneously). How do I pip install an enum file that has intflag? It looks like the enum from Python 3.1 has the intflag: https://github.com/python/cpython/blob/3.10/Lib/enum.py
Or is it that Python 2.7 doesn't have intflag in enum? Is the current FT4222 pip install tailored to Python 3 and not 2.7?
CodePudding user response:
According to the PYPI page, ft4222
only supports Python 3.7 , so you'll have to upgrade your Python or find a different library. I highly recommend upgrading to Python 3, given that Python 2 has been EOL for over 2 years now.
CodePudding user response:
The aenum
library has the same features as the stdlib enum (and more), and also supports 2.7 -- however, as @SuperStormer alludes to, ft4222
wants Python 3.7 or later and probably has other dependencies and/or uses other features not preset in Python 2.7.