Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode missing imports after creating project #517

Closed
maxi07 opened this issue Jun 23, 2023 · 4 comments
Closed

vscode missing imports after creating project #517

maxi07 opened this issue Jun 23, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@maxi07
Copy link

maxi07 commented Jun 23, 2023

Describe the bug
Hey there! I am trying to configure a new project for an esp32. With your tool i have downloaded the stubs and created a new project with the micropy cli. The project is created, but VS code still complains about failing to resolve the import machine.

image

Steps to Reproduce

  1. Create an empty vs code project
  2. Add esp32 stubs
  3. Init a new micropy project

The stubs then are added to the project and linked in the settings.json:

{
    // Loaded Stubs:  micropython-esp32-stubs  micropython-stdlib-stubs 
    
    "python.languageServer": "Pylance",
    "python.analysis.autoSearchPath": true,
    "python.autoComplete.extraPaths": [".micropy\\micropython_esp32_stubs-1.19.1.post12", ".micropy\\micropython-stdlib-stubs-0.9.0\\stdlib", ".micropy\\BradenM-micropy-stubs-4f5a52a\\frozen", ".micropy\\esptest"],
    "python.analysis.diagnosticSeverityOverrides": { "reportMissingModuleSource": "none" },
    "python.analysis.typeCheckingMode": "basic",
    "python.autoComplete.typeshedPaths":  [".micropy\\micropython_esp32_stubs-1.19.1.post12", ".micropy\\micropython-stdlib-stubs-0.9.0\\stdlib", ".micropy\\BradenM-micropy-stubs-4f5a52a\\frozen", ".micropy\\esptest", "typings"],
    "python.analysis.typeshedPaths":  [".micropy\\micropython_esp32_stubs-1.19.1.post12", ".micropy\\micropython-stdlib-stubs-0.9.0\\stdlib", ".micropy\\BradenM-micropy-stubs-4f5a52a\\frozen", ".micropy\\esptest", "typings"],
    
    

    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true
}

Please see my demo video here:

Microcli.1.mp4

But even after a vscode restart, the import cannot be resolved. I tracked your discussion #471, but this also does not work.

Logs
micropy.log

Context (Environment)

  • OS: Win 11 Version 10.0.22621.1848
  • Micropy Version: 4.2.1
  • Python Version: 3.11.3
  • VSCode Version: 1.79.2
@maxi07 maxi07 added the bug Something isn't working label Jun 23, 2023
@BradenM
Copy link
Owner

BradenM commented Jun 24, 2023

@maxi07 Thanks for the report.

But even after a vscode restart, the import cannot be resolved. I tracked your discussion #471, but this also does not work.

In the discussion you linked, I mentioned that opening the project in a vscode workspace causes this issue, but opening it directly works fine. In the video you attached, it appears you are opening in a workspace. Are you implying that you have also tried running code . from the newly created project directory and that still does not work?

@maxi07
Copy link
Author

maxi07 commented Jun 24, 2023

no, when i cd into the folder and open with code ., i still receive the same result.

Code.1.mp4

@BradenM
Copy link
Owner

BradenM commented Jun 25, 2023

@maxi07,

When you ran micropy init esptest inside the sources\repos\esptest directory, it created a new directory: sources\repos\esptest\esptest\

Therefore, you are opening the parent directory (sources\repos\esptest) and not the generated project directory. You should be running code esptest assuming you are within the sources\repos\esptest directory.

If it is your intention to create the project within sources\repos\esptest, then you should run micropy init .

@maxi07
Copy link
Author

maxi07 commented Jun 25, 2023

thank you, this solved the issue! perhaps something to mention in your documentation for getting started?

@maxi07 maxi07 closed this as completed Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants