2

Basically, I am cramming python into an embedded environment where I can't compile/configure it on the system itself. I am not surprised that the site module refuses to load; but that's okay, I don't need it. How do I control which modules python automatically imports?

Notes, this is a static build, and the only things I've copied to the working environment from the host are my static executable, and the contents of my /usr/lib/python/ directory (.py files) aka, no config files.

Community
  • 1
  • 1
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328

1 Answers1

2

Starting Python with the -S flag suppresses the automatic importing of the site module. Others, such as signal and readline, are actually built in. So you can just use the -S flag and then in your main script import what you need. Make sure you at least call sys.setdefaultencoding("ascii") (or "utf-8") early.

Keith
  • 42,110
  • 11
  • 57
  • 76