question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python unresolved import issue

See original GitHub issue

We believe the issue has been resolved, if not, please do open a new issue.

Locking this issue, to ensure we create a new issue.

Issue Type: Bug

I have python script which imports some libraries from subdirectories like this:

from easylog import EasyLog
from lib.fclib.misc import *
from lib.fclib.datelib import timestamp

with this directory hierachy:

  myscript.py
  lib
  |-__init__.py
  |-fclib
      |-__init__.py
      |-misc.py
      |-datelib.py

But VSCODE shows warnings like “unresolved import ‘lib.fclib.misc’ Python(unresolved-import)”. And the functions in the libs have so many warnings about the codes.

Extension version: 2018.12.1 VS Code version: Code 1.30.1 (dea8705087adb1b5e5ae1d9123278e178656186a, 2018-12-18T18:12:07.165Z) OS version: Windows_NT x64 10.0.16299

System Info
Item Value
CPUs Intel® Core™ i7-5600U CPU @ 2.60GHz (4 x 2594)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 7.88GB (1.36GB free)
Process Argv
Screen Reader no
VM 67%

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:57
  • Comments:35

github_iconTop GitHub Comments

43reactions
Spenhouetcommented, Feb 14, 2019

What @MagnusBrzenk hinted at also solved it for me.

Given the following example project structure:

  • workspaceRootFolder
    • .vscode
    • … other folders
    • codeFolder

What I did to resolve this issue:

  1. Go into the workspace folder (here workspaceRootFolder) and create a .env file
  2. In this empty .env file add the line PYTHONPATH=codeFolder (replace codeFolder with your folder name)
  3. Add "python.envFile": "${workspaceFolder}/.env" to the settings.json
  4. Restart VS code
29reactions
dkavraalcommented, Jan 9, 2019

The thumb ups may be confusing. I am having the same issue for the last two updates. When I > reload window that fixes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Pylint "unresolved import" error in Visual Studio Code
My solution · Go into the workspace folder (here workspaceRootFolder) and create a .env file · In this empty .env file, add the...
Read more >
Python unresolved import: How to Solve Pylint Error
To solve unresolved import error in Python, set your Python path in your workspace settings. If you are working with Visual Studio Code...
Read more >
Fix Python Unresolved Import in VSCode - LinuxPip
"Unresolved Import" is an error message produced by VSCode, not Python itself. The message simply means that VSCode cannot detect the correct ......
Read more >
Unresolved import of local python file if main script is not at ...
Issue: When importing your own python modules which are in the workspace folder, but the main script is not in the root directory...
Read more >
How to solve "unresolved import" (VS Code + Anaconda ...
Solving the " unresolved import " error in VS Code with 1 easy step!Resources:https://code.visualstudio.com/docs/ python /environmentshttps:// ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found