I am currently trying to load a few script through boost python. I ran into some trouble today while trying to launch idle from it however and I cannot figure out the cause of the issue.

This is on a windows 2008 machine, and I am currently running Python 3.3

import idlelib.PyShell
idlelib.PyShell.main()   

Those 2 lines produce this traceback:

    import idlelib.PyShell
  File "..\engines\idlelib\PyShell.py", line 20, in <module>
    from tkinter import *
  File "..\engines\tkinter\__init__.py", line 40, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk

UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character

Any ideas would be greatly appreciated!

I ran into some trouble today while trying to launch idle from it
from tkinter import *

For starters, you should not run apps that use Tkinter from Idle since Idle is written in Tkinter. The results are unpredictable, so try again without using Idle and post back if there are still errors.

If you read my original post, I am not using idle. I am using boost python, my script is loaded from a .dll

Yes you are, you import idlelib.PyShell.

Maybe I should have reworded that reply.. I am not running this code from idle. This code is being executed from a custom solution, where python itself is actually loaded as a .dll file instead of a .exe. (I compiled the setup to suit my purposes)

myexe.exe uses python.dll

MyExecutable.exe calls MyFile.py through boost python, which calls another file named MyIdle.py (it contains the 2 lines from the first post)

I have compiled all the relevant .dll files and nothing is missing. No libraries are missing. I just get this strange error while trying to use tkinter for anything, not just idle.

So I can assure you I am not calling this code from idle. (Besides that, you can run that code in idle without an issue!)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.