20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.73k stars 743 forks source link

Use Chinese Words Error #220

Open zhouxinsenGitHub opened 7 years ago

zhouxinsenGitHub commented 7 years ago

1 In my py file i used chinese word
and i get error : ValueError: source code string cannot contain null bytes the detail errors : Traceback (most recent call last): File "C:\Users\TIMO\AppData\Local\Programs\Python\Python36\Lib\imp.py", line 314, in reload return importlib.reload(module) File "C:\Users\TIMO\AppData\Local\Programs\Python\Python36\Lib\importlib__init__.py", line 166, in reload _bootstrap._exec(spec, module) File "", line 608, in _exec File "", line 674, in exec_module File "", line 781, in get_code File "", line 741, in source_to_code File "", line 205, in _call_with_frames_removed

2 this is my code : import unreal_engine as ue import redis

ue.log('Hello i am a Python module')

class Hero:

# this is called on game start
def begin_play(self):
    r = redis.Redis(host='192.168.0.2', port=32769)
    ue.log(r.get('你好'))
    ue.log('你好世界')

# this is called at every 'tick'    
def tick(self, delta_time):
    # get current location
    location = self.uobject.get_actor_location()
    # increase Z honouring delta_time
    location.z += 100 * delta_time
    # set new location
    self.uobject.set_actor_location(location)

3 ues ue.log('here') it's wrong the here can't be chinese word.

rdeioris commented 7 years ago

This is strange for python3, can you try with an embedded distribution ? Are you using the embedded editor or an external one ?

rdeioris commented 7 years ago

Oh, and in addition to this, avoid blocking calls in your code, to interface with redis, use asyncio:

https://github.com/20tab/UnrealEnginePython/blob/master/tutorials/AsyncIOAndUnrealEngine.md

zhouxinsenGitHub commented 7 years ago

I was using your PythonEditor and VsCode, both work. but when i work with blueprint and start run ureal scense it's wrong . How about python2.7 ?