Comments (10)
@HLammers No, the syntaxhighlighting and auto-completion is completely independent from the firmware installed on your board. The problem could be ~ as prefix for the user home in the vscode configuration. I have to do some test but I may have a solution to this.
from micropico.
I'm encountering similar symptoms with a new project
Does this also happen if you open a blank folder, run configure project and then create a main.py with import machine?
Yes, it does
Steps to reproduce on Windows 10:
- Create an empty folder
- In Visual Studio Code, select File | Open Folder, and select the newly created folder
- Run
MicroPython: Configure Project
- Create a
main.p
y file with the single lineimport machine
At this point, I see the error from Pylance: Import "machine" could not be resolved
My .vscode\settings.json
file contains this setting:
"python.analysis.extraPaths": [
"~\\.micropico-stubs\\included"
]
The micropico stubs do exist in my Windows user's home directory in a folder .micropico-stubs\included
As a workaround, I copied the .micropico-stubs directory from my home directory to my project directory. I changed the above lines in .vscode\settings.json
to also reference the project relative copy of the stubs:
"python.analysis.extraPaths": [
"~\\.micropico-stubs\\included",
".micropico-stubs\\included"
]
After saving .vscode\settings.json
, the error resolving import machine
goes away.
It appears that Pylance is not successfully using the stubs in my Windows user home directory.
from micropico.
I confirm the issue as well, @jimkr work around worked, instead of copying the whole directory I simply used the absolute path with my user account, for me being "C:\Users<user-name>l.micropico-stubs\included".
from micropico.
Does this also happen if you open a blank folder, run configure project and then create a main.py with import machine?
Yes
from micropico.
Does this also happen if you open a blank folder, run configure project and then create a main.py with import machine?
from micropico.
Does this also happen if you open a blank folder, run configure project and then create a main.py with import machine?
Yes, I can confirm that as well.
I haven’t tried @jimkr’s work around yet.
from micropico.
Following @sandylnur's suggestion to add the absolute path of the users folder to settings.json, partly resolves the problem, but not completely. It recognises machine
, but it doesn't recognise parts of gc
and time
:
import gc
is recognised, so aregc.enable()
andgc.collect()
, butgc.threshold()
,gc.mem_free()
andgc.mem_alloc()
are not.import time
is recognised, buttime.sleep_ms()
,time.ticks_ms()
andtime.ticks_diff()
are not.
from micropico.
it doesn't recognise parts of gc and time
I'd guess that pylance is using the python standard library versions of time and gc, which contain different methods. It's not using the micropython stubs, so isn't aware of the micropython functions.
I'm not sure how (or whether it's even possible) to make the micropython stubs take precedence.
from micropico.
Could it have something to do with the version of MicroPython I'm using (1.23)? I don't think it should, because it used to be working when I was using the 1.23 preview.
from micropico.
Error in Python Language server output with absolute path entered into pylance settings "include" paths and nothing in settings.json:
2024-06-17 14:52:54.371 [info] Auto-Indent enabled
2024-06-17 14:52:54.377 [info] [Info - 2:52:54 PM] (20844) Setting pythonPath for service "Firmware": "C:\Program Files (x86)\Python310-32\python.exe"
2024-06-17 14:52:54.377 [info] [Info - 2:52:54 PM] (20844) Setting environmentName for service "Firmware": "3.10.11 (global)"
2024-06-17 14:52:54.576 [info] [Info - 2:52:54 PM] (20844) Assuming Python version 3.10.11.final.0
2024-06-17 14:52:54.867 [info] [Info - 2:52:54 PM] (20844) Found 143 source files
2024-06-17 14:52:54.908 [info] Auto-Indent enabled
2024-06-17 14:52:54.909 [info] [Info - 2:52:54 PM] (20844) Setting environmentName for service "Pico (W) Remote Workspace": "3.10.11 (global)"
2024-06-17 14:52:55.166 [info] [Error - 2:52:55 PM] (20844) File or directory "pico:c%3A/users/#######/.micropico-stubs/included" does not exist.
2024-06-17 14:52:55.208 [info] [Info - 2:52:55 PM] (20844) No source files found.
2024-06-17 14:52:55.214 [info] Auto-Indent enabled
from micropico.
Related Issues (20)
- 'MicroPico:Extra > Switch stubs' resulted in an error (wrong path)
- Debug variables
- [error] Invalid version for /usr/bin/python HOT 2
- How can I get a listing of the files already on the Pico? HOT 2
- MicroPico disconnect won't free serial port HOT 3
- friendly names for additional sync folders
- Project configuration fails when creating new project on external drive HOT 4
- repl not reading print data when not in while true loop
- pico keeps disconnecting and reconnecting when i try to run a script on it HOT 8
- Upload/ Sync syncFIleTypes seems to not respected when editing
- Sync Folder seems to not respected settings.json HOT 4
- Switch stubs throw syntax error "&" unexpected HOT 1
- Working on two Raspberry Pi Picos in two workspaces, uploading code copies to both
- Under Linux, cannot connect ot Pico HOT 3
- stubs for @rp2.asm_pio PIO methods HOT 6
- Uploading a file to Pico with spaces in its name - explorer does't show file HOT 1
- wrapper_win32_amd64.exe detected as malware by Microsoft Defender on 1 Jun 2024 HOT 3
- Sync/Connection breaks on stopping multi-threaded program in Pico HOT 3
- Switch Stubs resulted in an error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropico.