1

I installed recordclass via pip3 install recordclass which installs it under /Users/timothee/homebrew/lib/python3.7/site-packages/recordclass; I'm trying to use it from a sublimetext package but it fails:

import sys
sys.path.append('/Users/timothee/homebrew/lib/python3.7/site-packages')
import recordclass
ImportError: No module named 'recordclass.mutabletuple'

If I instead use sys.path.append('/Users/timothee/homebrew/lib/python3.7/site-packages/recordclass') I get: SystemError: Parent module '' not loaded, cannot perform relative import

Note that it does work for some other pip3 installed modules, eg jstyleson, simplejson.

Here is contents of recordclass:

\ls
__init__.py                             arrayclass.py                           datatype.py                             mutabletuple.cpython-37m-darwin.so      recordobject.cpython-37m-darwin.so      test                                    utils.py
__pycache__                             dataobject.cpython-37m-darwin.so        litelist.cpython-37m-darwin.so          recordclass.py                          structclass.py                          typing

Not sure whether the reason is that sublime bundles its own python interpreter (3.3 IIRC) and my system python is 3.7, and it installs as recordobject.cpython-37m-darwin.so so can't be seen by sublime's python; but temporarily renaming to recordobject.cpython-33m-darwin.so didn't help.

Note: I've read other similar questions but these didn't help, eg: * Install python module without PIP => not relevant; I can install it; just not load it from sublime * Installing python modules like "Web3" without pip/pip3? ditto * https://github.com/SublimeText/UnitTesting/issues/67

This is the most relevant post: Sublime Plugin: How can I import wx? but the solution there doesn't seem to work; since the problem seems to be these darwin.so files in my case

timotheecour
  • 3,104
  • 3
  • 26
  • 29
  • "I'm trying to use it from a sublimetext package" – does this mean you're *developing* a Sublime Text package (as in plugin) which relies on a third-party module? – idleberg Aug 07 '19 at 20:52
  • it's for customizing my sublime text editor, not necessarily meant for publishing it as a sublime text package, so I'm ok with any dirty hacks so long it works – timotheecour Aug 08 '19 at 21:37
  • The version of Python that Sublime uses is 3.3.6; the ABI changes when the version of Python changes, so any package with byte code or native code will only work if it was compiled for python 3.3.6. There are a few ways you can get external modules to be seen in Sublime (modifying the `sys.path` or dropping them into the Sublime `DATA` directory at `Lib/python3.3`) but if the module has an external library or compiled byte code, you're likely out of luck. – OdatNurd Aug 13 '19 at 04:05

0 Answers0