0

setting : win10 + vs2015 (Debug 32bits) + anaconda3 (32bits)

#include <iostream> 
#include <stdio.h>
#include <stdlib.h>
#include <Python.h>
#include <string.h>

using namespace std;

int main()
{

    Py_Initialize();
    PyRun_SimpleString("import pylab");
    PyRun_SimpleString("pylab.plot(range(5))");
    PyRun_SimpleString("pylab.show()");
    Py_Exit(0);

    return 0;
}

When it runs, program crash.

Crash image

AndyG
  • 39,700
  • 8
  • 109
  • 143
LaoJiu
  • 69
  • 7
  • Is this relevant? http://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings Also, please check this thread: https://bugs.python.org/issue27054 – AndyG Apr 26 '17 at 13:35
  • make sure the environment variables are correctly set, especially `PYTHONHOME`. – zmo Apr 26 '17 at 13:38

1 Answers1

0

According to this Python thread you need to install Python 3.x as administrator. Right click on installer > run as administrator

Also, please check your environment variables after installation to ensure that PYTHONPATH and PYTHONHOME have been set to locations where your installed modules can be found.

AndyG
  • 39,700
  • 8
  • 109
  • 143
  • pythonhome and pythonpath are ok. I failed again, anyway, 3Q. I use python2, and i just make it. – LaoJiu Apr 28 '17 at 07:43