python 操作同花顺下单程序_Py(76)Python/C API 参考手册:操作系统实用程序

操作系统实用程序

  • PyObject* PyOS_FSPath(PyObject *path)

  • Return value: New reference.

    Return the file system representation for path. If the object is a str or bytes object, then its reference count is incremented. If the object implements the os.PathLike interface, then __fspath__() is returned as long as it is a str or bytes object. Otherwise TypeError is raised and NULL is returned.

    3.6 新版功能.

  • int Py_FdIsInteractive(FILE *fp, const char *filename)

  • Return true (nonzero) if the standard I/O file fp with name filename is deemed interactive. This is the case for files for which isatty(fileno(fp)) is true. If the global flag Py_InteractiveFlag is true, this function also returns true if the filename pointer is NULL or if the name is equal to one of the strings '' or '???'.

  • void PyOS_BeforeFork()

  • Function to prepare some internal state before a process fork. This should be called before calling fork() or any similar function that clones the current process. Only available on systems where fork() is defined.

    警告

    The C fork() call should only be made from the "main" thread (of the "main" interpreter). The same is true for PyOS_BeforeFork().

    3.7 新版功能.

  • void PyOS_AfterFork_Parent()

  • Function to update some internal state after a process fork. This should be called from the parent process after calling fork() or any similar function that clones the current process, regardless of whether process cloning was successful. Only available on systems where fork() is defined.

    警告

    The C fork() call should only be made from the "main" thread (of the "main" interpreter). The same is true for PyOS_AfterFork_Parent().

    3.7 新版功能.

  • void PyOS_AfterFork_Child()

  • Function to update internal interpreter state after a process fork. This must be called from the child process after calling fork(), or any similar function that clones the current process, if there is any chance the process will call back into the Python interpreter. Only available on systems where fork() is defined.

    警告

    The C fork() call should only be made from the "main" thread (of the "main" interpreter). The same is true for PyOS_AfterFork_Child().

    3.7 新版功能.

    参见

    os.register_at_fork() allows registering custom Python functions to be called by PyOS_BeforeFork()PyOS_AfterFork_Parent() and PyOS_AfterFork_Child().

  • void PyOS_AfterFork()

  • Function to update some internal state after a process fork; this should be called in the new process if the Python interpreter will continue to be used. If a new executable is loaded into the new process, this function does not need to be called.

    3.7 版后已移除: This function is superseded by PyOS_AfterFork_Child().

  • int PyOS_CheckStack()

  • Return true when the interpreter runs out of stack space. This is a reliable check, but is only available when USE_STACKCHECK is defined (currently on Windows using the Microsoft Visual C++ compiler). USE_STACKCHECK will be defined automatically; you should never change the definition in your own code.

  • PyOS_sighandler_t PyOS_getsig(int i)

  • Return the current signal handler for signal i. This is a thin wrapper around either sigaction() or signal(). Do not call those functions directly! PyOS_sighandler_t is a typedef alias for void (*)(int).

  • PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)

  • Set the signal handler for signal i to be h; return the old signal handler. This is a thin wrapper around either sigaction() or signal(). Do not call those functions directly! PyOS_sighandler_t is a typedef alias for void (*)(int).

  • wchar_t* Py_DecodeLocale(const char* arg, size_t *size)

  • Decode a byte string from the locale encoding with the surrogateescape error handler: undecodable bytes are decoded as characters in range U+DC80..U+DCFF. If a byte sequence can be decoded as a surrogate character, escape the bytes using the surrogateescape error handler instead of decoding them.

    Encoding, highest priority to lowest priority:

    Return a pointer to a newly allocated wide character string, use PyMem_RawFree() to free the memory. If size is not NULL, write the number of wide characters excluding the null character into *size

    Return NULL on decoding error or memory allocation error. If size is not NULL*size is set to (size_t)-1 on memory error or set to (size_t)-2 on decoding error.

    Decoding errors should never happen, unless there is a bug in the C library.

    Use the Py_EncodeLocale() function to encode the character string back to a byte string.

    参见

    The PyUnicode_DecodeFSDefaultAndSize() and PyUnicode_DecodeLocaleAndSize() functions.

    3.5 新版功能.

    在 3.7 版更改: The function now uses the UTF-8 encoding in the UTF-8 mode.

    在 3.8 版更改: The function now uses the UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is zero;

    • UTF-8 on macOS, Android, and VxWorks;

    • UTF-8 on Windows if Py_LegacyWindowsFSEncodingFlag is zero;

    • UTF-8 if the Python UTF-8 mode is enabled;

    • ASCII if the LC_CTYPE locale is "C"nl_langinfo(CODESET) returns the ASCII encoding (or an alias), and mbstowcs() and wcstombs() functions uses the ISO-8859-1 encoding.

    • the current locale encoding.

  • char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos)

  • Encode a wide character string to the locale encoding with the surrogateescape error handler: surrogate characters in the range U+DC80..U+DCFF are converted to bytes 0x80..0xFF.

    Encoding, highest priority to lowest priority:

    The function uses the UTF-8 encoding in the Python UTF-8 mode.

    Return a pointer to a newly allocated byte string, use PyMem_Free() to free the memory. Return NULL on encoding error or memory allocation error

    If error_pos is not NULL*error_pos is set to (size_t)-1 on success, or set to the index of the invalid character on encoding error.

    Use the Py_DecodeLocale() function to decode the bytes string back to a wide character string.

    参见

    The PyUnicode_EncodeFSDefault() and PyUnicode_EncodeLocale() functions.

    3.5 新版功能.

    在 3.7 版更改: The function now uses the UTF-8 encoding in the UTF-8 mode.

    在 3.8 版更改: The function now uses the UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is zero;

    • UTF-8 on macOS, Android, and VxWorks;

    • UTF-8 on Windows if Py_LegacyWindowsFSEncodingFlag is zero;

    • UTF-8 if the Python UTF-8 mode is enabled;

    • ASCII if the LC_CTYPE locale is "C"nl_langinfo(CODESET) returns the ASCII encoding (or an alias), and mbstowcs() and wcstombs() functions uses the ISO-8859-1 encoding.

    • the current locale encoding.

431ebcb1160d191503cb456518117783.png

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误提示是说在执行/opt/ros/melodic/_setup_util.py这个文件时,使用的是/usr/bin/python解释器,但是该解释器找不到对应的文件或目录。可能是因为你的系统中没有安装Python或者Python的路径设置不正确。建议检查一下Python的安装和路径设置,或者尝试使用其他的Python解释器来执行该文件。 ### 回答2: 这个错误提示说明是在使用ROS开发时遇到了问题。/opt/ros/melodic/_setup_util.py是ROS安装时自动创建的一个文件,它的作用是设置ROS环境变量。而/usr/bin/pythonPython的默认解释器路径,这个错误提示说的是找不到这个路径下的文件或目录。解释器错误一般是由于Python版本问题引起的。 这个错误可能的原因有以下几个: 1.没有安装Python:解决方法是先安装Python,安装完成后再去运行ROS。 2.Python版本不符合:可能ROS需要的Python版本与本地Python版本不一致,可以通过升级或降级本机Python版本来解决。 3.系统Python解释器路径与ROS中预设的不一样:ROS环境变量设置不正确,需要重新配置或检查。 4.ROS安装不完全或出现文件损坏:重新安装或修复ROS软件包,重新构建环境变量。 针对这个错误提示,我们可以按照以下步骤来尝试解决问题: 1.首先检查Python是否安装,如果没有安装就先安装Python。安装完Python后再重新启动ROS。 2.检查Python版本是否与ROS要求的版本一致,如果不一致则需要升级或降级Python版本。可以通过查询ROS的文档来查看要求的Python版本。 3.检查ROS环境变量是否正确设置,ROS会根据每个新打开的终端设置一些特定的环境变量,可以查看ROS的相关文档来进行参考。 4.如果以上方法还是无法解决问题,可以尝试卸载ROS并重新安装,同时确保该过程完全完成。如果还是无法解决,可能需要求助ROS社区或教练。 ### 回答3: 这个错误提示表明,用户在运行脚本时,出现了无法找到解释器的错误。具体地说,这个错误是由于系统在执行安装在/opt/ros/melodic/_setup_util.py中的python脚本时,无法找到文件或目录所导致的。 一种解决方法是检查系统中是否存在/usr/bin/python的解释器。用户可以在终端中输入“whereis python”命令来检查系统的Python解释器路径。如果找不到python是因为它没有被安装,则可以通过运行“sudo apt-get install python”安装Python解释器。 如果系统中已经存在Python解释器,那么就需要检查路径是否正确。可能的原因是,安装包或解释器路径没有被正确配置。用户可以运行“which python”命令来确定解释器的实际路径。如果输出的路径与错误信息不一致,则需要重新配置解释器路径。通常情况下,需要在配置文件bashrc中添加以下行:export PATH=/usr/bin/python:$PATH 在更新完配置后,最好重启终端并再次尝试运行脚本。如果仍然遇到了相同的错误,请检查安装路径是否正确,并确保系统中已经安装了所有必需的软件和软件包。 总之,bash: /opt/ros/melodic/_setup_util.py: /usr/bin/python: 解释器错误: 没有那个文件或目录这个错误提示是由于系统找不到Python解释器或路径不正确所引起的。用户可以通过检查路径并重新配置解释器路径来解决这个问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值