0

I woke up this morning and found that half my standard library "went missing". It was working fine earlier this week. I haven't made any major system config changes in the past few days that would affect my Python installation (I don't think).

Basically, the following modules now throw "No module named x" errors from the REPL: math, time, itertools, functools

The following modules continue to work: os, sys, abc, thread

I haven't tested all the modules, but is there some way to debug this? Another side effect appears to be that the "up" and "down" arrows now print ^[[A and ^[[B instead of scrolling through history.

My Python is located at /Library/Frameworks/Python.framework/Versions/2.7/bin/python, discovered via which python.

I've verified that all standard library files do indeed exist in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7.

Running os.environ['PYTHONPATH'] returns a KeyError, which seems strange, but I've never had to explicitly set the PYTHONPATH before, and haven't modified my bash profile in the last few weeks.

I wasn't able to find anything relating to this specific issue, but I could well be missing something obvious. Any help is appreciated, thanks!

the_lrner
  • 575
  • 1
  • 5
  • 11
  • I'm pretty sure the 'working' list correlates to `sys.builtin_module_names`; these are *compiled in* in your Python binary. The other modules would have to be loaded dynamically, they are compiled (binary) extensions, and this in turn would point to `DYLD_LIBRARY_PATH` on Mac. Perhaps it is time you read `man dyld`. – Martijn Pieters Aug 18 '16 at 16:25
  • @MartijnPieters: That doesn't seem to be it. `sys` and `thread` are compiled in, but `os` and `abc` are ordinary modules. – user2357112 Aug 18 '16 at 16:37
  • @user2357112: `os` and `abc` are pure python modules and don't need to be compiled in. `os` uses the `posix` C module on Mac OS X to do the difficult work, which *is* compiled into the Python binary. `abc` depends only on `_weakrefset` (pure Python), which in turn uses `_weakref`, a built-in C module. – Martijn Pieters Aug 18 '16 at 16:47

0 Answers0