Can it be that UE4 ditched all the basic python features like time, logging, …?
When I try to import it I really get weird errors that they can’t be linked, see below.
I really need these standard functionalities, not because of the unreal extension, but to extend the editor with other features, that don’t interact with unreal in the first way.
LogPython: import time
LogPython: Error: Traceback (most recent call last):
LogPython: Error: File "<string>", line 1, in <module>
LogPython: Error: ImportError: /opt/dev/unrealengine/4.22/Engine/Binaries/ThirdParty/Python/Linux/lib/python2.7/lib-dynload/time.so: undefined symbol: PyExc_ValueError
LogPython: import logging
LogPython: Error: Traceback (most recent call last):
LogPython: Error: File "<string>", line 1, in <module>
LogPython: Error: File "/opt/dev/unrealengine/4.22/Engine/Binaries/ThirdParty/Python/Linux/lib/python2.7/logging/__init__.py", line 26, in <module>
LogPython: Error: import sys, os, time, cStringIO, traceback, warnings, weakref, collections
LogPython: Error: ImportError: /opt/dev/unrealengine/4.22/Engine/Binaries/ThirdParty/Python/Linux/lib/python2.7/lib-dynload/time.so: undefined symbol: PyExc_ValueError
Could it be possible to just change the python version inside of unreal to get these features working?
Okay,
so upgrading to UE4.23.0 fixes these python errors.
import time works fine now!
But, importing other modules (like PyQt) does not work, as I’m getting errors like this:
PyQt4/QtCore.so: undefined symbol: PyUnicodeUCS4_AsLatin1String
Does anyone know what’s that all about? Does UE4 use another Unicode length?
Okay, fixed it with rebuilding the python api with the flag --enable-unicode=ucs4 in build_python_linux.sh
Hi msearl0001, thank you for posting this. I’ve run into the same issue. I wonder if you wouldn’t mind explaining a bit further. I made that change to build_python_linux.sh and ran it, but then how do I get Unreal to use that Python? Who uses this Python-Linux.tar that it creates? Why is there a RunMe.bat in here? Any help would be much appreciated
Hi,
so I’ve changed the /configure part in build_linux_python.sh to the following to also enable SSL in the python build. You have to build the ssl package first.
MY_PREFIX=/.../openssl-1.0.2t/release/usr/local/ssl
./configure --enable-optimizations --enable-shared --enable-unicode=ucs4 \
LDFLAGS="-L$MY_PREFIX/lib -L$MY_PREFIX/lib64 -Wl,-rpath=$MY_PREFIX/lib" \
LD_LIBRARY_PATH="$MY_PREFIX/lib:$MY_PREFIX/lib64" \
CPPFLAGS="-I$MY_PREFIX/include -I$MY_PREFIX/ssl -fPIC" \
Then the probably easiest solution is to copy the lib and header files to the Engine/Source/ThirdParty/Python/Linux folder.
Another way is to go to the Python.Build.cs file and add this at line 27:
if (PythonSDK == null)
{
var customBuildPath = Path.Combine(EngineDir, "Source/ThirdParty/Python/Build/Linux/usr/local");
Console.WriteLine("Custom Python SDK path: " + customBuildPath);
if (Target.Platform == UnrealTargetPlatform.Linux)
{
PythonSDK = DiscoverPythonSDK(customBuildPath);
}
}
This should get you working. Maybe you also have to check if the DiscoverPythonSDK works correctly with your build Python SDK version.
Cheers