I am trying to make a plugin for Sublime Text 3. I have a simple script loaded that uses the enum
module.
However, when I import enum
, I get an import error:
ImportError: No module named 'enum'
Using sys.version
, I found that the version of Python run by Sublime is:
3.3.6 (default, Feb 2 2017, 05:49:32)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
It seems that enum
is only available in Python v3.4+ . Is there a way to load the enum
module from the version of Python I have installed globally (v3.6.3)?
After some additional searches, I found a general solution to this issue. Although it's for Sublime 2 plugins, it seems to work for Sublime Text 3 as well.
I downloaded and unarchived the enum
module from PyPi. I made the folder a subdirectory of my python script, and added the following before the enum
import statement:
sys.path.append(os.path.join(os.path.dirname(__file__), "<dir_name>"))
where <dir_name>
was the name I gave to the directory containing the enum
code.