How I can fix this issue. #1745
Unanswered
zydjohnHotmail
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Environment
Details
Describe what you were trying to get done.
I want to play a MP4 format video using Pythonnet.
The corresponding python code works.
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
My code in CSharp:
using Python.Runtime;
namespace PyReturnTransit1Result
{
class Program
{
public const string MP4_File1 = "D:/Videos/1.mp4";
public static void Python_Play_Video()
{
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
dynamic cv2 = Py.Import("cv2");
dynamic cap = cv2.VideoCapture(MP4_File1);
while (cap.isOpened())
{
var video_frame = cap.read();
cv2.imshow("frame", video_frame);
}
cap.release();
cv2.destroyAllWindows();
}
}
}
The run time errors:
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\PythonNet\PyPlayVideo\PyPlayVideo\bin\x64\Debug\net5.0\PyPlayVideo.exe'
sys.base_prefix = 'C:\Program Files\Python39'
sys.base_exec_prefix = 'C:\Program Files\Python39'
sys.platlibdir = 'lib'
sys.executable = 'C:\PythonNet\PyPlayVideo\PyPlayVideo\bin\x64\Debug\net5.0\PyPlayVideo.exe'
sys.prefix = 'C:\Program Files\Python39'
sys.exec_prefix = 'C:\Program Files\Python39'
sys.path = [
'C:\Program Files\Python39\python39.zip',
'.\DLLs',
'.\lib',
'C:\PythonNet\PyPlayVideo\PyPlayVideo\bin\x64\Debug\net5.0',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00009094 (most recent call first):
From the above errors, I saw one funny thing:
sys.path = [
'C:\Program Files\Python39\python39.zip',
From Windows 10 PC, I can't see such file: 'C:\Program Files\Python39\python39.zip'
There are other files, like:
'C:\Program Files\Python39\python39.exe, C:\Program Files\Python39\python39.dll, C:\Program Files\Python39\python3.dll, C:\Program Files\Python39\pythonw.exe, C:\Program Files\Python39\vcruntime140.dll, C:\Program Files\Python39\vcruntime140_1.dll
Please advise on how to fix this issue.
Thanks,
All reactions