Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The module has no attribute 'TCP_KEEPIDLE'#2606

Unanswered
wumin199 asked this question inQ&A
Discussion options

my environment:

  • python 3.13
  • .net: 8
  • win 10

my c# test code is:

            using (Py.GIL())            {                dynamic socket = Py.Import("socket");                Console.WriteLine($"socket.SO_KEEPALIVE: {socket.SO_KEEPALIVE}"); // 8                try                {                    var tcp_keepidle = socket.TCP_KEEPIDLE;                }                catch (Exception e)                {                    Console.WriteLine($"socket.TCP_KEEPIDLE error: {e.Message}");                }            }

My question is why it raise exception in var tcp_keepidle = socket.TCP_KEEPIDLE, which shows errorsocket.TCP_KEEPIDLE error: The module has no attribute 'TCP_KEEPIDLE'.

but if I test in ipython, there is no error here in getting socket.TCP_KEEPIDLE.

ipython:

import socket socket.__dir__()

it has attributes

'TCP_KEEPIDLE',
'TCP_KEEPINTVL',
'TCP_KEEPCNT',

but these attributes lost in C# environtment:

                dynamic socket = Py.Import("socket");                dynamic dir_result = socket.__dir__();                string[] dir_result_list = dir_result.As<string[]>();

Also I testsocket.__file__ in ipython and C# , they both point to same socket.py

my python environment setting is

            string py_path = Path.Combine(XSPkgPythonPath) + Path.PathSeparator.ToString();  // my local python packages            py_path += Path.Combine(PythonEmbededPath, "DLLs") + Path.PathSeparator.ToString();            py_path += Path.Combine(PythonEmbededPath, "Lib") + Path.PathSeparator.ToString();            py_path += PythonEmbededPath + Path.PathSeparator.ToString();            py_path += Path.Combine(PythonEmbededPath, "Lib", "site-packages") + Path.PathSeparator.ToString();            py_path += Path.Combine(PythonEmbededPath, "Lib", "site-packages", "win32") + Path.PathSeparator.ToString();            py_path += Path.Combine(PythonEmbededPath, "Lib", "site-packages", "win32", "lib") + Path.PathSeparator.ToString();            py_path += Path.Combine(PythonEmbededPath, "Lib", "site-packages", "pythonwin");           Runtime.PythonDLL = Path.Combine(PythonEmbededPath, "python313.dll");           PythonEngine.PythonHome = PythonEmbededPath;             PythonEngine.PythonPath = py_path;           PthonEngine.Initialize();           PythonEngine.BeginAllowThreads();
You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Are you sure that you are using the exact same Python for this check? According to the docs, Win 10 1709 is required for the flag.

You must be logged in to vote
1 reply
@wumin199
Comment options

I‘m sure python is the same for this test, As I only have only one python environment in my computer

And my win 10 version is newer than Win 10 1709
image

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@wumin199@filmor
Converted from issue

This discussion was converted from issue#2605 on July 20, 2025 09:41.


[8]ページ先頭

©2009-2025 Movatter.jp