<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[py编译报错]]></title><description><![CDATA[<p dir="auto">虚拟机 Ubuntu22.04 使用一键安装 ROS2，机器安装的 python3.10，<a href="http://setup.py" target="_blank" rel="noopener noreferrer nofollow ugc">setup.py</a> 文件 使用 setup() 时报错</p>
<pre><code>  File "/home/nli/.local/lib/python3.10/site-packages/sphinx/util/typing.py", line 34, in &lt;module&gt;
    from types import Union as types_Union
ImportError: cannot import name 'Union' from 'types' (/usr/lib/python3.10/types.py)
</code></pre>
<p dir="auto">发现是安装后上面报错定位的代码有逻辑问题，修改为如下可以正常编译</p>
<pre><code>if sys.version_info &gt; (3, 10):
    from typing import Union as types_Union
else:
    from types import Union as types_Union
    # types_Union = None
</code></pre>
]]></description><link>https://fishros.org.cn/forum/topic/4709/py编译报错</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 03:17:27 GMT</lastBuildDate><atom:link href="https://fishros.org.cn/forum/topic/4709.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Jan 2026 02:08:26 GMT</pubDate><ttl>60</ttl></channel></rss>