How can I get VSCODE Pico-go and CircuitPython extension commands to work - visual-studio-code

I have installed pico-go extension in VSCode. When I do any View>Command Palette>Pico-Go > Help > Show Pico Pin Map... I always get Command 'Pico-Go > Help > Show Pico Pin Map' resulted in an error (command 'picogo.extra.pins' not found).
I get a similar error for any pico-go command. I have installed different versions of the Pico-go code, did restart after each and the problem is exhibited in all the versions I have tested. Pico-go states that it is dependent on Python 3 and Python3.9.1 that is installed and running in VSCode.
I have the same problem using CircuitPython commands on both systems. The Dependencies list includes Python and Juypter which are both installed.
I have a second system that has pico-go installed and it works properly. I do not know how to isolate what is wrong in the first system.
Even if I get this problem solved the getting started code
from machine import Pin
import time
pin = Pin(25, Pin.out)
while True:
pin.toggle()
time.sleep_ms(1000)
fails with
File "e:\code.py", line 1, in <module>
from machine import Pin
ModuleNotFoundError: No module named 'machine'

Make sure you click the RUN that's at the bottom of the screen (in the window border) and not the tempting one at the top. The one at the top will run your Python code on your computer, which doesn't know what the Machine any other Pico-specific library is. The one at the bottom sends the code to the Pico and runs it there - you can confirm because "Pico Console" will be listed and not "Python".

Related

import requests ModuleNotFoundError: No module named 'requests' in VSCode

I ran the code import requests in my file and this error come out ModuleNotFoundError: No module named 'requests'
Things I have tried:
installed requests in both windows terminal and vscode terminal that gives the output Requirement already satisfied
Make sure you have the right python interpreter selected in the lower right hand corner of the VSCode window. If it's not right, you can change it by clicking on the interpreter version:

VSCode hangs when trying to run a Jupyter notebook?

I am trying to run a Jupyter notebook in VSCode. I have successfully run notebooks in the past, but something has happened to make VSCode "hang" when I try running. When I hit run, the terminal shows the file location and the location of python.exe as expected (shown in the first image, with some personal information redacted), but nothing ever happens. The code never completes and the cells never output. I get a small "pending" icon of a clock and an arrow (shown in the second image) to tell me a cell is running, but even the most basic "Hello, world" never completes or gives an error. I have no trouble running regular python files, and if I export an ipynb to py I can run it, but I cannot run the ipynb itself. Trying to restart the Jupyter kernel also seems to hang, never completing and never crashing or erroring. The only clue I really have is that when I hit F5 to run, there's no python version showing in the bottom left corner, the way there is when I run py files (third image is while trying to run ipynb and fourth image is while successfully running py).
I have tried uninstalling and reinstalling the Jupyter extension from VSCode and restarting VSCode between every step. I have tried swapping between python.exe and conda.exe in the terminal settings python.condapath. I have checked that the windows terminal is cmd. I've tried creating new notebooks in VSCode that only have print("Hello, world"). I have tried the command "Select interpreter to start Jupyter server" and selected the correct version of Python, but nothing has changed any time I've tried to run.
I am using Anaconda version 4.10.3, VSCode 1.61.2, IPython version 7.9.0, and Jupyter notebook version 6.4.3.

VS Code importing the multiarray numpy extension module failed

import numpy
is not working. This started because I couldn't get PyQt5 to work on my home computer. In the Spyder IDE, I can import modules and get everything working fine, but in VS Code, I can't import basic modules. I'm on Windows 10 with Python 3.7. I've Googled a lot and have tried these:
Uninstall Anaconda and VS Code, and reinstall both
In VS Code, press Ctrl+Shift+P, Select Interpreter, and select Python 3.7.1 64-bit ('base':conda), ~\Anaconda3\python.exe
I saw on another similar question that python3.dll may be missing from one of my Anaconda directories, but it is indeed there.
Add environment variable to PATH by going to System Properties > Advanced tab > Environment Variables... > under System Path, Edit, New > C:\Users\myname\Anaconda3\Scripts
Once I did #4 above, the new error message in VS Code when importing numpy is DLL load failed: The specified module could not be found. And in the terminal, I see: The term 'conda' is not recognized as the name of the cmdlet, ...
One thing I notice is in a Python prompt (not Anaconda) I type:
import sys
print(sys.version)
The output is 3.7.2, while in VS Code, the Select Interpreter (see above #2) says Python 3.7.1. Not sure if this is important.
Any help? Everything works on my work computer fine, but it's just my home computer that is being difficult.
What ended up working for me is downgrading my Python installation from 3.7.1 to 3.6.4 with:
conda install python=3.6.4
Hope this helps someone out there.
On another question for the same problem, there was a suggestion that worked for me.
Put this on the variable path.
C:\Users\<Your user name>\Anaconda3\Library\bin
credit to user1024.

vscode on Windows 10: Activating extension ... failed: Module did not self-register

This problem has been brought up a few times and I tried every suggested solution, but nothing helped.
What I have is a native module in a VS code extension. This works very well on Linux + Mac, but I cannot get it to load on Windows 10. Every time the extension is activated and tries to load the native module I get this error. What makes this so strange is that the native module works beautifully in a node session (in a Win command line). I checked what NodeJS version Visual Studio Code uses and installed exactly this version (x86, as vscode is still 32bit). I did an npm install npm -g, ran npm rebuild as well as normal node-gyp rebuild in my extension folder (or node module folder for node-gyp). Every time the module is built fine and works in a node session. Still I cannot get it to work in vscode. So I believe it must be something that has to do with the vscode app on Windows, just don't know what it is. For compilation I tried both VS 2013 and VS 2015.
Interesting here is also how node-gyp compiles the native module on Windows. It appears as if it uses a number of hacks, e.g. the compiled module crashs hard when using std::throw_with_nested (a C++11 feature). Another problem is the win_delay_load_hook.cc file, which contains a hack to make some weird situation work (this init fails on Win 10, so I had to disable that, this is a general DLL init problem not related to the vscode init). So it could well be it's just node-gyp on Win10 which is causing all the trouble. Yet, as I wrote, the native module works nicely in a node session.
What else could I do to find out what exactly is the problem? Is there a log file that shows exactly why the registration is not right? Is there a problem with vscode in general, on Windows 10?

Display of music21, musicXML PNG objects using iPython Notebook/Enthought Canopy

I am experimenting with the music21 library, in preparation for a Machine Learning project that involves genre classification and categorization. I and following some tutorials available here. I am using MuseScore as my MusicXML program, and I am trying to run the whole thing from iPython.
Although I can run the some of the turtorials from the terminal, some elements don't seem to run well from inside iPython. For example:
In [3]: sBach.show()
Out[3]: <music21.ipython21.objects.IPythonPNGObject at 0x10da0aa10>
The line above shows that the PNG object is created, but not displayed. The expected output for 3 above is the following:
Experimenting with the following iPython command, I get a placeholder for an image, but not image.
In [6]: %load_ext music21.ipython21.ipExtension
In [7]: sBach.show()
I can't find any problem with my MusicXMLPath. This tutorial refers to the use of musc21 with Anaconda, but all my developments is done with Enthought, so I prefer not to run another virtual environment to use music21 with iPython.
Is there any way to run music21 in an Enthought/iPython notebook?
I have been grappling with this issue myself. ... Have you set your musicxmlPath in music21? If you have not, it's done via environment.set(key, value). You can query for available keys with environment.keys(). I hope this isn't too simple an answer, but it cleared up the problem for me.
This should be in the iPython music21 documentation somewhere, my apologies: iPython in music21 requires Lilypond to be installed for images to be generated within the notebook itself. There hasn't been (and won't be until MuseScore 2.0 is released) a way using MusicXML to generate PNG images of scores directly.
Edit: 2015 July; music21 2.0 w/ MuseScore 2 will generate the PNG images with MuseScore if it is installed and fallback to Lilypond if it is not installed.
If not yet tried, some steps to isolate the cause of the problem:
1) Update to the latest Canopy (Edit: currently 1.4.1) (might help this, will help generally, won't hurt).
2) Change the Pylab backend in Canopy's IPython shell to "Inline (SVG)", via Preferences / Python. (The default Qt backend in that shell conflicts with music21's use of the tkinter library.)
3) Test your script in that shell rather than in the notebook.
4) Ensure that Canopy User Python is your default Python in a Terminal window, as described here.
5) Test your scripts inside of plain ipython terminal (from Terminal, type ipython).
6) Test in ipython terminal in pylab mode (ipython qtconsole --pylab=inline).
7) Test your scripts inside of ipython notebook running in a regular browser (from Terminal, type ipython notebook, and/or ipython notebook --pylab=inline).
Had similar issues before. It's the same problem when people try to use plot function in ipython/jupyter notebook. You need to call
%matplotlib inline
For me the issue was solved by uninstalling the snap version of musescore and installing it from ppa:mscore-ubuntu/mscore3-stable via https://launchpad.net/~mscore-ubuntu/+archive/ubuntu/mscore3-stable