<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CLI can&amp;#39;t build code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87073/cli-can-t-build-code</link><description>Hi ~~ 
 I can&amp;#39;t use CLI(command line interface) to build code, but VS Code is workable. 
 CLI build log: 
 
 VS Code build log : 
 
 Error message (cut from CLI build log ): 
 
 I guess maybe python location miss match. 
 
 VS code python location : </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Apr 2022 03:33:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87073/cli-can-t-build-code" /><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364799?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 03:33:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42dbde6d-9691-4756-b9ee-b9af8e6188f7</guid><dc:creator>PrinceKuo</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Thanks for your passion and helping. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I have a good news that&amp;#39;s I fixing the issue through modifying cmake file to assign SDK&amp;#39;s Python while building. I try to record what I did&amp;nbsp;and hope that can help who has the same issue.&lt;/p&gt;
&lt;p&gt;As my build server environment, SDK&amp;#39;s Python location is &amp;quot;&lt;span&gt;/opt/nordic/ncs/v1.8.0/toolchain/opt/python@3.9/bin/python3.9&lt;/span&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;step 1. Launch cmake file&amp;nbsp;that&amp;nbsp;response for detecting Python location&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;vim $(Nordic_SDK_folder)/zephyr/cmake&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;step 2. Assign target Python location in cmake file&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;set(PYTHON_PREFER_EXECUTABLE &amp;quot;/opt/nordic/ncs/v1.8.0/toolchain/opt/python@3.9/bin/python3.9&amp;quot;)&lt;/pre&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650943719400v1.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now I can build code through CLI.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Prince&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364397?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 08:24:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22210d5d-526a-4bd0-8d02-41f7f9898188</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Prince,&lt;/p&gt;
&lt;p&gt;I talked to one of the developers of nRF Connect for Visual Studio Code. He told me you could try this:&lt;/p&gt;
&lt;p&gt;&amp;quot;python3 -m west build --build-dir ...&amp;quot;&lt;/p&gt;
&lt;p&gt;And if that doesn&amp;#39;t work, then:&lt;/p&gt;
&lt;p&gt;&amp;quot;/full/path/to/python -m west build --build-dir ...&amp;quot;&lt;/p&gt;
&lt;p&gt;where you replace /full/path/to/python with the full path to the python executable that you want to use, so the one inside the toolchain folder.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364378?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 07:45:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a32b3124-f03b-4ea7-888e-b0664c9c2291</guid><dc:creator>PrinceKuo</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;I test &amp;#39;alias&amp;#39;, the python version really update.&lt;/p&gt;
&lt;p&gt;But cmake get python location still wrong, so build process still fail...Orz&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650613671690v2.png" /&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650613513925v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you have any idea?&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s very strange and hard, appreciate for your great supporting.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Prince&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364360?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 06:47:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9409f02-3691-49e4-a711-2dce88286f77</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Oh. I thought it was the mac that you were testing on next to your build server. To be honest, I am not sure if you are actually using two computers, or if the build server (which is a mac) is the only computer you are using.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="PKuo"]Could you share me how to let CLI reference to SDK&amp;#39;s python folder?[/quote]
&lt;p&gt;I see that you are asking for this in every post, but I don&amp;#39;t know a simple answer to this. Did you test the stackoverflow link in my initial reply? I don&amp;#39;t have a mac to test this on, but you need to find some way that your command line sees the version that you want to use instead of the other (wrong) version. This doesn&amp;#39;t need to be permanent, but when you are building, the command line (terminal) needs to see that version. I don&amp;#39;t know how to do that. You need to do a bit of research.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to do some research, and it ended up in the link in my first reply. The reply&amp;nbsp;that discusses&amp;nbsp;using the &amp;quot;alias&amp;quot; in the terminal.&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364338?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 01:17:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:889d4535-79db-4b2d-b935-90f8c286fcde</guid><dc:creator>PrinceKuo</dc:creator><description>&lt;p&gt;Yap, previous post that is build server&amp;#39;s screenshot.&lt;/p&gt;
&lt;p&gt;So in my build server already had correctly python folder and VS Code can reference it.&lt;/p&gt;
&lt;p&gt;But CLI will reference to system&amp;#39;s python not SDK&amp;#39;s.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you share me how to let CLI reference to SDK&amp;#39;s python folder?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Prince&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364187?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 10:59:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8437677-9d5b-40cc-bc56-9c6fa5f6b1eb</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Prince,&lt;/p&gt;
&lt;p&gt;I believe the yaml is missing because python can&amp;#39;t find it. So solving the python issue should solve the yaml issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On your build server, do you have the folder and executable (correct version of) python inside the toolchain folder?&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/364166?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 10:00:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c20188c-5a0f-4807-9136-c99e2e044828</guid><dc:creator>PrinceKuo</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Thanks for your information, but I still your support...Orz&lt;/p&gt;
&lt;p&gt;Base on build fail message&amp;nbsp;&lt;span style="font-size:inherit;"&gt;&lt;em&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;strong&gt;No module named &amp;#39;yaml&amp;#39;&lt;/strong&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;we know cmake can&amp;#39;t find &amp;#39;yaml&amp;#39; module while building.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  File &amp;quot;/opt/nordic/ncs/v1.8.0/zephyr/scripts/dts/gen_defines.py&amp;quot;, line 33, in &amp;lt;module&amp;gt;
    from devicetree import edtlib
  File &amp;quot;/opt/nordic/ncs/v1.8.0/zephyr/scripts/dts/python-devicetree/src/devicetree/edtlib.py&amp;quot;, line 77, in &amp;lt;module&amp;gt;
    import yaml
ModuleNotFoundError: No module named &amp;#39;yaml&amp;#39;
CMake Error at /opt/nordic/ncs/v1.8.0/zephyr/cmake/dts.cmake:251 (message):
  gen_defines.py failed with return code: 1
Call Stack (most recent call first):
  /opt/nordic/ncs/v1.8.0/zephyr/cmake/app/boilerplate.cmake:545 (include)
  /opt/nordic/ncs/v1.8.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /opt/nordic/ncs/v1.8.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
  CMakeLists.txt:44 (find_package)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I search &amp;#39;yaml&amp;#39; on my Mac and find it location under Nordic SDK.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650534886628v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;So do you know how to let cmake detecting python location to Nordic SDK(&lt;span&gt;/opt/nordic/ncs/v1.8.0/toolchain/opt/python@3.9/bin/python3.9.&lt;/span&gt;)?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Prince&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/363936?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 12:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66d90826-e05b-45a2-a4d1-ee028b46b82e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;The answer to your question on &amp;quot;why the sample doesn&amp;#39;t build&amp;quot; looks like it is that you have the wrong version of python. If you are telling me that you can&amp;#39;t update the python version on the computer that you are building on, then I don&amp;#39;t know how to fix it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I know that in Windows you can use the env.cmd file to set temporary workspaces/toolchains, but I don&amp;#39;t know how to do that on a Mac. I also don&amp;#39;t have a mac that I can experiment on.&lt;/p&gt;
&lt;p&gt;Perhaps this discussion can give some clues on how to set a specific python version:&lt;br /&gt;&lt;a href="https://gitlab.kitware.com/cmake/cmake/-/issues/19492"&gt;https://gitlab.kitware.com/cmake/cmake/-/issues/19492&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/363829?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 09:23:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d1df4d3-585e-4812-b35e-7116c2066bf4</guid><dc:creator>PrinceKuo</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Thanks for your replying.&lt;/p&gt;
&lt;p&gt;But my build server (Mac mini) without &amp;quot;&lt;span&gt;/opt/nordic/ncs/v1.8.0/toolchain/&lt;/span&gt;cmd/&amp;quot; folder.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Because toolchain can&amp;#39;t complement install SDK in my build server, so I almost download all files by manual.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BTW, do you know how to setup cmake environment variable PYTHON_EXECUTABLE?&lt;/p&gt;
&lt;p&gt;Seem like this environment variable let build fail.&lt;/p&gt;
&lt;p&gt;Build fail path:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650446746519v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Build success path:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650446855407v2.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Prince&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CLI can't build code</title><link>https://devzone.nordicsemi.com/thread/363774?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 07:42:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ece64f42-76e2-4959-ab6a-4e51260b3259</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Prince,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know how you installed NCS, but since you are able to build it using nRF Connect for VS Code, you have the proper toolchain installed on the computer, at least.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In Windows, you would call this file from the command line, which will set up all the tools you need in that command line window, without changing anything externally.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;/opt/nordic/ncs/v1.8.0/toolchain/cmd/env.cmd&lt;/p&gt;
&lt;p&gt;But I am not familiar with Mac or linux. Perhaps you can try something like this to temporary change the python path:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://stackoverflow.com/a/43354441"&gt;https://stackoverflow.com/a/43354441&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>