{"id":7694,"date":"2021-11-08T10:41:23","date_gmt":"2021-11-08T18:41:23","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=7694"},"modified":"2023-09-28T14:22:17","modified_gmt":"2023-09-28T21:22:17","slug":"troubleshooting-mbed-python-errors","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/documentation\/troubleshooting\/mbed\/","title":{"rendered":"Troubleshooting Mbed Python Errors"},"content":{"rendered":"<p>If you encounter problems importing or building mbed projects, please try resetting your Python environment as shown on this page.<\/p>\n<ol>\n<li>Clear the <strong>Tools-&gt;Options-&gt;VisualGDB-&gt;General-&gt;Tools-&gt;Python Directory setting<\/strong>:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/python.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7695\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/python.png\" alt=\"\" width=\"700\" height=\"475\" \/><\/a>See <a href=\"https:\/\/visualgdb.com\/documentation\/python\/\">this page<\/a> for more information about Python packages managed by VisualGDB.<\/li>\n<li>Delete the <strong>%LOCALAPPDATA%\\VisualGDB\\Python* <\/strong> directories.<\/li>\n<li>Restart Visual Studio and open the Mbed Project Wizard. When prompted to install Python, try installing the latest Python 3:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/getpython.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7696\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/getpython.png\" alt=\"\" width=\"700\" height=\"567\" \/><\/a>This will install a version of Python that was tested with mbed scripts on our side, and it should work exactly as described in our <a href=\"https:\/\/visualgdb.com\/w\/tutorials\/tag\/mbed\/\">mbed tutorials<\/a>.<\/li>\n<li>If you still get an error while trying to clone an mbed repository, the selected mbed version might be referencing packages that are not available in the currently used Python version. If this happens, click the &#8220;Show output from failed command&#8221; link in the error message shown by VisualGDB:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/clone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7697\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/clone.png\" alt=\"\" width=\"499\" height=\"196\" \/><\/a>The log will contain output similar to the one shown below:\n<pre class=\"\">Run \"C:\\Users\\virtual.SYSPROGS\\AppData\\Local\\VisualGDB\\Python3\\python.exe \"C:\\Users\\virtual.SYSPROGS\\AppData\\Local\\VisualGDB\\Python3\\lib\\site-packages\\mbed\\mbed.py\" update mbed-os-6.9.0\" in directory \"c:\\projects\\temp\\MbedProject2\\mbed-os\" on local computer\r\n--------------------------\r\nRequirement already satisfied: colorama==0.3.9 in c:\\users\\virtual.sysprogs\\appdata\\local\\visualgdb\\python3\\lib\\site-packages (from -r c:\\projects\\temp\\MbedProject2\\mbed-os\\requirements.txt (line 1)) (0.3.9)\r\n&lt;...&gt;\r\nERROR: Could not find a version that satisfies the requirement pywin32==224 (from versions: 225, 226, 227, 228, 300, 301, 302)\r\nERROR: No matching distribution found for pywin32==224\r\nWARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.\r\nYou should consider upgrading via the 'C:\\Users\\virtual.SYSPROGS\\AppData\\Local\\VisualGDB\\Python3\\python.exe -m pip install --upgrade pip' command.\r\n--------------------------\r\nCommand exited with code 1<\/pre>\n<p>Take a note of the following parameters:<\/p>\n<ol>\n<li>Python executable used to run the command (in this example, <strong>C:\\Users\\virtual.SYSPROGS\\AppData\\Local\\VisualGDB\\Python3\\python.exe<\/strong>)<\/li>\n<li>The requirements file (in this example, <strong>c:\\projects\\temp\\MbedProject2\\mbed-os\\requirements.txt<\/strong>)<\/li>\n<li>The exact package versions that failed (in this example, <strong>pywin32==224<\/strong>) and the available versions (in this example, 225..302)<\/li>\n<\/ol>\n<\/li>\n<li>In order to make that mbed version work, you will need to adjust the <strong>requirements.txt<\/strong> file to reference the nearest package version provided by your Python distro. In this example, it would mean replacing the following line in requirements.txt:\n<pre class=\"\">pywin32==224;platform_system=='Windows'<\/pre>\n<p>with the following one:<\/p>\n<pre class=\"\">pywin32==225;platform_system=='Windows'<\/pre>\n<\/li>\n<li>Now you can re-run the &#8220;mbed update&#8221; command as shown in the log file, e.g.:\n<pre class=\"\">cd c:\\projects\\temp\\MbedProject2\\mbed-os\r\nC:\\Users\\virtual.SYSPROGS\\AppData\\Local\\VisualGDB\\Python3\\python.exe \"C:\\Users\\virtual.SYSPROGS\\AppData\\Local\\VisualGDB\\Python3\\lib\\site-packages\\mbed\\mbed.py\" update mbed-os-6.9.0<\/pre>\n<\/li>\n<li>Now you can import the manually patched mbed checkout into VisualGDB by selecting the &#8220;import&#8221; mode in the wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7698\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/import.png\" alt=\"\" width=\"856\" height=\"693\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you encounter problems importing or building mbed projects, please try resetting your Python environment as shown on this page.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[202],"tags":[115,191],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7694"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=7694"}],"version-history":[{"count":6,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7694\/revisions"}],"predecessor-version":[{"id":8445,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7694\/revisions\/8445"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=7694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=7694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=7694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}