<?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[PYTHONPATH not appended to sys.path in Cinema 4D 24]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">We've been using Cinema 4D R20 and R21 for some years and now we're preparing to migrate to the S24.</p>
<p dir="auto">During these years, we've developed some Python Packages that are imported by our Python plugins.</p>
<p dir="auto">In C4D 20 and 21 these modules have always been imported by the plugin with no errors.</p>
<p dir="auto">In C4D 24, however, the same operation raises a "<em>ModuleNotFoundError: No module named ...</em>"</p>
<p dir="auto">The paths to our packages are appended to <em>PYTHONPATH</em> environment variable before launching C4D.</p>
<p dir="auto">Once C4D is launched, I've checked the <em>PYTHONPATH</em> in the <strong>Extension &gt; Console &gt; Python</strong> and the packages' paths are all there.</p>
<p dir="auto">The <em><strong>sys.path</strong></em> however doesn't contain the Packages Path, as if the <em>$PYTHONPATH</em> were not inserted into the <em><strong>sys.path</strong></em> upon launching C4D.</p>
<p dir="auto">Do you know if this is a known issue and if there's a "workaround" for importing external python packages in our C4D plugins (any workaround besides looping through the <em>PYTHONPATH</em> paths and appending them to the <em><strong>sys.path</strong></em>)?</p>
<p dir="auto">These tests were executed from Cinema S24.111 on Windows 10 Enterprise.</p>
<p dir="auto">Thanks for your help,<br />
Rodrigo<br />
Ps.: This issue seems to be related to the issue described in <a href="https://developers.maxon.net/forum/topic/11143/content-of-pythonpath-not-appended-to-sys-path" target="_blank" rel="noopener noreferrer nofollow ugc">https://developers.maxon.net/forum/topic/11143/content-of-pythonpath-not-appended-to-sys-path</a>. However, as the latter is focused on other versions of C4D and as it was marked as "solved", I've preferred to create a new topic.</p>
]]></description><link>http://developers.maxon.net/forum//topic/13885/pythonpath-not-appended-to-sys-path-in-cinema-4d-24</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Mar 2026 04:56:16 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum//topic/13885.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Apr 2022 14:13:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PYTHONPATH not appended to sys.path in Cinema 4D 24 on Sat, 12 Nov 2022 22:51:53 GMT]]></title><description><![CDATA[<p dir="auto">Excellent! Thanks you a lot</p>
<p dir="auto">Regards,</p>
]]></description><link>http://developers.maxon.net/forum//post/70144</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/70144</guid><dc:creator><![CDATA[f2b]]></dc:creator><pubDate>Sat, 12 Nov 2022 22:51:53 GMT</pubDate></item><item><title><![CDATA[Reply to PYTHONPATH not appended to sys.path in Cinema 4D 24 on Fri, 11 Nov 2022 11:27:20 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/f2b">@<bdi>f2b</bdi></a>,</p>
<p dir="auto">Thank you for reaching out to us. In R21, you must use <code>PYTHONPATH</code>. This all is dependent on the <em>CPython</em> version your Cinema 4D is using. When this topic came up, I took the occasion to update our Python documentation on <a href="https://developers.maxon.net/docs/py/2023_2/manuals/introduction/python_libraries.html" target="_blank" rel="noopener noreferrer nofollow ugc">Python Libraries</a>. There you will find information on the multiple approaches one can use to include Python libraries with one or multiple Cinema 4D installations.</p>
<p dir="auto">The caveat is, however, that <code>R21</code> is technically out of scope of SDK support and therefore <code>PYTHONPATH</code> is not included on that page, but I will fix that. For me this works without issues:</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1668165263587-f7ff6efc-9a6f-4794-a4d3-f18d43c98044-image.png" alt="f7ff6efc-9a6f-4794-a4d3-f18d43c98044-image.png" class=" img-fluid img-markdown" /><br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1668165301454-3e54cf95-738f-4162-b297-8ff4d300ced3-image.png" alt="3e54cf95-738f-4162-b297-8ff4d300ced3-image.png" class=" img-fluid img-markdown" /><br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1668165447763-pythonpathr21.gif" alt="pythonpathr21.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto">The slight problem with the R21 module search path <code>PYTHONPATH</code> is that it is shared with the standard <code>CPython</code> interpreter when you happen to have one on your machine.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum//post/70127</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/70127</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Fri, 11 Nov 2022 11:27:20 GMT</pubDate></item><item><title><![CDATA[Reply to PYTHONPATH not appended to sys.path in Cinema 4D 24 on Thu, 10 Nov 2022 23:33:24 GMT]]></title><description><![CDATA[<p dir="auto">Hello, how do you use C4DPYTHONPATH environnement variable with C4D R21?</p>
<p dir="auto">C4DPYTHONPATH is not appended to sys.path</p>
<p dir="auto">I created it in windows environement variables, and then i launch C4D R21, when i type "import moduleX" the module could not be imported...</p>
<p dir="auto">Cheers</p>
]]></description><link>http://developers.maxon.net/forum//post/70124</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/70124</guid><dc:creator><![CDATA[f2b]]></dc:creator><pubDate>Thu, 10 Nov 2022 23:33:24 GMT</pubDate></item><item><title><![CDATA[Reply to PYTHONPATH not appended to sys.path in Cinema 4D 24 on Thu, 14 Apr 2022 19:27:07 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I didn't know we could/should set this environment variable in C4D 24.<br />
Thanks Ferdinand for your help!<br />
Cheers,<br />
Rodrigo</p>
]]></description><link>http://developers.maxon.net/forum//post/68754</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/68754</guid><dc:creator><![CDATA[rodrigo]]></dc:creator><pubDate>Thu, 14 Apr 2022 19:27:07 GMT</pubDate></item><item><title><![CDATA[Reply to PYTHONPATH not appended to sys.path in Cinema 4D 24 on Thu, 14 Apr 2022 15:55:16 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/rodrigo">@<bdi>rodrigo</bdi></a>,</p>
<p dir="auto">Thank you for reaching out to us. With S24 you must setup an environment variable called <code>C4DPYTHONPATH39</code> to achieve an effect similar to <code>PYTHONPATH</code>:</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1649951520451-f94e9eb0-3d41-4b9c-994e-502de30b723a-image.png" alt="f94e9eb0-3d41-4b9c-994e-502de30b723a-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">S24 will then be able to import modules and packages from that path.</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1649951645576-env_var.gif" alt="env_var.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum//post/68753</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/68753</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Thu, 14 Apr 2022 15:55:16 GMT</pubDate></item></channel></rss>