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.

opencv-python intellisense is not working under conda

See original GitHub issue

From @sarkarstanmoy on April 3, 2017 18:4

Environment data

VS Code version: latest Python Extension version:
Python Version: 3.5 OS and version: windows 10

Actual behavior

After installing and importing opencv-python package in my project file intellisense is not firing up.

Expected behavior

Steps to reproduce:

  • Install opencv-python 3.2.0.6 using pip
  • Import package into project (import cv2 as cv)
  • Try to fire intellisense using cv.

Settings

Your launch.json (if dealing with debugger issues):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "PySpark",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "osx": {
                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
            },
            "windows": {
                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit.cmd"
            },
            "linux": {
                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
            },
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Python Module",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "module": "module.name",
            "cwd": "${workspaceRoot}",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Integrated Terminal/Console",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "cwd": "null",
            "console": "integratedTerminal",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit"
            ]
        },
        {
            "name": "External Terminal/Console",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "cwd": "null",
            "console": "externalTerminal",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit"
            ]
        },
        {
            "name": "Django",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${workspaceRoot}/manage.py",
            "cwd": "${workspaceRoot}",
            "args": [
                "runserver",
                "--noreload"
            ],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput",
                "DjangoDebugging"
            ]
        },
        {
            "name": "Flask",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "pythonPath": "${config.python.pythonPath}",
            "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
            "cwd": "${workspaceRoot}",
            "env": {
                "FLASK_APP": "${workspaceRoot}/quickstart/app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Flask (old)",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${workspaceRoot}/run.py",
            "cwd": "${workspaceRoot}",
            "args": [],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Watson",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${workspaceRoot}/console.py",
            "cwd": "${workspaceRoot}",
            "args": [
                "dev",
                "runserver",
                "--noreload=True"
            ],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "${workspaceRoot}",
            "port": 3000,
            "secret": "my_secret",
            "host": "localhost"
        }
    ]
}

Your settings.json:

// Display prompt to install Jupyter Extension.
  "python.promptToInstallJupyter": true,

  // Path to Python, you can use a custom version of Python by modifying this setting to include the full path.
  "python.pythonPath": "python",

  // Path to folder with a list of Virtual Environments (e.g. ~/.pyenv, ~/Envs, ~/.virtualenvs).
  "python.venvPath": "",

  // Absolute path to a file containing environment variable definitions.
  "python.envFile": "${workspaceRoot}/.env",

  // Path to directory containing the Jedi library (this path will contain the 'Jedi' sub directory).
  "python.jediPath": "",

  // Path to isort script, default using inner version
  "python.sortImports.path": "",

  // Arguments passed in. Each argument is a separate item in the array.
  "python.sortImports.args": [],

  // Whether to lint Python files.
  "python.linting.enabled": true,

  // Whether to lint Python files when no workspace is opened.
  "python.linting.enabledWithoutWorkspace": true,

  // Whether to lint Python files using prospector.
  "python.linting.prospectorEnabled": false,

  // Whether to lint Python files using pylint.
  "python.linting.pylintEnabled": true,

  // Whether to lint Python files using pep8
  "python.linting.pep8Enabled": false,

  // Whether to lint Python files using flake8
  "python.linting.flake8Enabled": false,

  // Whether to lint Python files using pydocstyle
  "python.linting.pydocstyleEnabled": false,

  // Whether to lint Python files using mypy.
  "python.linting.mypyEnabled": false,

  // Whether to lint Python files when modified.
  "python.linting.lintOnTextChange": true,

  // Whether to lint Python files when saved.
  "python.linting.lintOnSave": true,

  // Controls the maximum number of problems produced by the server.
  "python.linting.maxNumberOfProblems": 100,

  // Severity of Pylint message type 'Convention/C'.
  "python.linting.pylintCategorySeverity.convention": "Information",

  // Severity of Pylint message type 'Refactor/R'.
  "python.linting.pylintCategorySeverity.refactor": "Hint",

  // Severity of Pylint message type 'Warning/W'.
  "python.linting.pylintCategorySeverity.warning": "Warning",

  // Severity of Pylint message type 'Error/E'.
  "python.linting.pylintCategorySeverity.error": "Error",

  // Severity of Pylint message type 'Fatal/F'.
  "python.linting.pylintCategorySeverity.fatal": "Error",

  // Path to Prospector, you can use a custom version of prospector by modifying this setting to include the full path.
  "python.linting.prospectorPath": "prospector",

  // Path to Pylint, you can use a custom version of pylint by modifying this setting to include the full path.
  "python.linting.pylintPath": "pylint",

  // Path to pep8, you can use a custom version of pep8 by modifying this setting to include the full path.
  "python.linting.pep8Path": "pep8",

  // Path to flake8, you can use a custom version of flake8 by modifying this setting to include the full path.
  "python.linting.flake8Path": "flake8",

  // Path to pydocstyle, you can use a custom version of pydocstyle by modifying this setting to include the full path.
  "python.linting.pydocstylePath": "pydocstyle",

  // Path to mypy, you can use a custom version of mypy by modifying this setting to include the full path.
  "python.linting.mypyPath": "mypy",

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.prospectorArgs": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.pylintArgs": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.pep8Args": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.flake8Args": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.pydocstyleArgs": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.mypyArgs": [
    "--ignore-missing-imports",
    "--follow-imports=silent"
  ],

  // The output window name for the linting messages, defaults to Python output window.
  "python.linting.outputWindow": "Python",

  // Provider for formatting. Possible options include 'autopep8' and 'yapf'.
  "python.formatting.provider": "autopep8",

  // Path to autopep8, you can use a custom version of autopep8 by modifying this setting to include the full path.
  "python.formatting.autopep8Path": "autopep8",

  // Path to yapf, you can use a custom version of yapf by modifying this setting to include the full path.
  "python.formatting.yapfPath": "yapf",

  // Arguments passed in. Each argument is a separate item in the array.
  "python.formatting.autopep8Args": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.formatting.yapfArgs": [],

  // Format the document upon saving.
  "python.formatting.formatOnSave": false,

  // The output window name for the formatting messages, defaults to Python output window.
  "python.formatting.outputWindow": "Python",

  // Comma delimited list of modules preloaded to speed up Auto Complete (e.g. add Numpy, Pandas, etc, items slow to load when autocompleting).
  "python.autoComplete.preloadModules": [],

  // List of paths to libraries and the like that need to be imported by auto complete engine. E.g. when using Google App SDK, the paths are not in system path, hence need to be added into this list.
  "python.autoComplete.extraPaths": [],

  // Automatically add brackets for functions.
  "python.autoComplete.addBrackets": false,

  // Fully qualified path to tag file (exuberant ctag file), used to provide workspace symbols.
  "python.workspaceSymbols.tagFilePath": "${workspaceRoot}/.vscode/tags",

  // Set to 'false' to disable Workspace Symbol provider using ctags.
  "python.workspaceSymbols.enabled": true,

  // Whether to re-build the tags file on start (deaults to true).
  "python.workspaceSymbols.rebuildOnStart": true,

  // Whether to re-build the tags file on when changes made to python files are saved.
  "python.workspaceSymbols.rebuildOnFileSave": true,

  // Fully qualilified path to the ctags executable (else leave as ctags, assuming it is in current path).
  "python.workspaceSymbols.ctagsPath": "ctags",

  // Pattern used to exclude files and folders from ctags See http://ctags.sourceforge.net/ctags.html.
  "python.workspaceSymbols.exclusionPatterns": [
    "**/site-packages/**"
  ],

  // Where to prompt to configure a test framework if potential tests directories are discovered.
  "python.unitTest.promptToConfigure": true,

  // Port number used for debugging of unittests.
  "python.unitTest.debugPort": 3000,

  // Whether to enable or disable unit testing using nosetests.
  "python.unitTest.nosetestsEnabled": false,

  // Path to nosetests, you can use a custom version of nosetests by modifying this setting to include the full path.
  "python.unitTest.nosetestPath": "nosetests",

  // Whether to enable or disable unit testing using pytest.
  "python.unitTest.pyTestEnabled": false,

  // Path to pytest (py.test), you can use a custom version of pytest by modifying this setting to include the full path.
  "python.unitTest.pyTestPath": "py.test",

  // Arguments passed in. Each argument is a separate item in the array.
  "python.unitTest.nosetestArgs": [],

  // Arguments passed in. Each argument is a separate item in the array.
  "python.unitTest.pyTestArgs": [],

  // Whether to enable or disable unit testing using unittest.
  "python.unitTest.unittestEnabled": false,

  // Arguments passed in. Each argument is a separate item in the array.
  "python.unitTest.unittestArgs": [
    "-v",
    "-s",
    ".",
    "-p",
    "*test*.py"
  ],

  // Patterns used to exclude files or folders from being linted.
  "python.linting.ignorePatterns": [
    ".vscode/*.py",
    "**/site-packages/**/*.py"
  ],

  // Whether to lint Python files using pylama.
  "python.linting.pylamaEnabled": false,

  // Path to pylama, you can use a custom version of pylama by modifying this setting to include the full path.
  "python.linting.pylamaPath": "pylama",

  // Arguments passed in. Each argument is a separate item in the array.
  "python.linting.pylamaArgs": [],

  // The output window name for the unit test messages, defaults to Python output window.
  "python.unitTest.outputWindow": "Python Test Log",

  // When executing a file in the terminal, whether to use execute in the file's directory, instead of the current open folder.
  "python.terminal.executeInFileDir": false,

  // Python launch arguments to use when executing a file in the terminal.
  "python.terminal.launchArgs": [],

  // Whether to appen the results to results window, else clear and display.
  "python.jupyter.appendResults": true,

  // Default kernel to be used. By default the first available kernel is used.
  "python.jupyter.defaultKernel": "",

  // Code executed when the kernel starts. Such as the default of '%matplotlib inline'. Individual lines can be placed in separate items of the array.
  "python.jupyter.startupCode": [
    "%matplotlib inline"
  ],

Logs

Output from Python output panel

Output from Console window (Help->Developer Tools menu)

Copied from original issue: DonJayamanne/pythonVSCode#858

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DonJayamannecommented, Feb 26, 2018

@anribras @ironbar @denck007 Please could you download the Insiders Build and test this out. Note: This isn’t the insiders build of VS Code, its our dev version of the extension. It contains a number of fixes related to intellisense, and I’m hoping this resolves the issue you are experiencing.

Please test and let me know how it goes.

2reactions
anribrascommented, Feb 9, 2018

Meet same issue. cv2 (opencv 3.4) intellisense complied into python3.5 on ubuntu 16.04 did not work at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intellisense in vscode not working on openCV that is on conda ...
I am a Mac M1 Pro user, and the past couple of days have been working with the openCV library. Initially, I had...
Read more >
Problem in VisualStudio2019-python-intelliSense for module ...
I have some problems on vs2019 python project. When I import cv2, it seems that intelliSense can not work well. Codes that intelliSense...
Read more >
Code completion doesn't work for cv2 module : PY-35691
Code is working but PyCharm can't find reference for imread and autocomplete for cv2 methods doesn't work in editor. But, works in Python...
Read more >
Autocomplete | Python in Visual Studio Code
1. Intellisense/Autocompletion not working for custom modules · Cause: The path to the python executable is incorrect. Solution: Configure the path to the...
Read more >
Pycharm Autocomplete for Custom OpenCV with Anaconda3 ...
Although Anaconda comes with a prebuilt OpenCV package, ... no warning should be pointed by PyCharm and the autocomplete should work like a...
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