Skip to content

opencv-python intellisense is not working under conda #99

Description

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

Activity

  1. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Nilesh Kevlani (@njkevlani) on July 27, 2017 17:57

    Facing the same issue..
    ezgif-4-d91b1e4f36

  2. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Siddhartha Gandhi (@gandhis1) on July 27, 2017 19:20

    Can you use the Jedi API to determine whether it is a Jedi issue?

  3. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Nilesh Kevlani (@njkevlani) on July 27, 2017 19:24

    Can you explain it in a better way? Siddhartha Gandhi (@gandhis1)

  4. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Siddhartha Gandhi (@gandhis1) on July 27, 2017 20:26

    Import jedi. Take, the code, put it in the jedi.Script constructor, and then call .completions(). Do you get any results?

    E.g.

    print(jedi.Script("import cv2\ncv2.").completions())

    See below for more information:

    https://jedi.readthedocs.io/en/latest/docs/plugin-api.html

  5. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Nilesh Kevlani (@njkevlani) on July 27, 2017 20:45

    Here you go:
    [<Completion: abs>, <Completion: all>, <Completion: any>, <Completion: ArithmeticError>, <Completion: ascii>, <Completion:assert>, <Completion: AssertionError>, <Completion: async>, <Completion: AttributeError>, <Completion: await>, <Completion: BaseException>, <Completion: bin>, <Completion: BlockingIOError>, <Completion: bool>, <Completion: break>, <Completion: BrokenPipeError>, <Completion: BufferError>, <Completion: bytearray>, <Completion: bytes>, <Completion: BytesWarning>, <Completion: callable>, <Completion: ChildProcessError>, <Completion: chr>, <Completion: class>, <Completion: classmethod>, <Completion: compile>, <Completion: complex>, <Completion: ConnectionAbortedError>, <Completion: ConnectionError>, <Completion:ConnectionRefusedError>, <Completion: ConnectionResetError>, <Completion: continue>, <Completion: copyright>, <Completion:credits>, <Completion: cv2>, <Completion: def>, <Completion: del>, <Completion: delattr>, <Completion: DeprecationWarning>, <Completion: dict>, <Completion: dir>, <Completion: divmod>, <Completion: Ellipsis>, <Completion: enumerate>, <Completion: EnvironmentError>, <Completion: EOFError>, <Completion: eval>, <Completion: Exception>, <Completion: exec>, <Completion: exit>, <Completion: False>, <Completion: FileExistsError>, <Completion: FileNotFoundError>, <Completion: filter>, <Completion: float>, <Completion: FloatingPointError>, <Completion: for>, <Completion: format>, <Completion: from>, <Completion: frozenset>, <Completion: FutureWarning>, <Completion: GeneratorExit>, <Completion: getattr>, <Completion: global>, <Completion: globals>, <Completion: hasattr>, <Completion: hash>, <Completion: help>, <Completion: hex>, <Completion: id>, <Completion: if>, <Completion: import>, <Completion: ImportError>, <Completion: ImportWarning>, <Completion: IndentationError>, <Completion: IndexError>, <Completion: input>, <Completion: int>, <Completion: InterruptedError>, <Completion: IOError>, <Completion: IsADirectoryError>, <Completion: isinstance>, <Completion: issubclass>, <Completion: iter>, <Completion: KeyboardInterrupt>, <Completion: KeyError>, <Completion: lambda>, <Completion: len>, <Completion: license>, <Completion: list>, <Completion: locals>, <Completion: LookupError>, <Completion: map>, <Completion: max>, <Completion: MemoryError>, <Completion: memoryview>, <Completion: min>, <Completion: NameError>, <Completion: next>, <Completion: None>, <Completion: nonlocal>, <Completion: not>, <Completion: NotADirectoryError>, <Completion: NotImplemented>, <Completion: NotImplementedError>, <Completion: np>, <Completion: object>, <Completion: oct>, <Completion: open>, <Completion: ord>, <Completion: OSError>, <Completion: OverflowError>, <Completion: pass>, <Completion: PendingDeprecationWarning>, <Completion: PermissionError>, <Completion: pow>, <Completion: print>, <Completion: process>, <Completion: ProcessLookupError>, <Completion: property>, <Completion: quit>, <Completion: raise>, <Completion: range>, <Completion: RecursionError>, <Completion: ReferenceError>, <Completion: repr>, <Completion: ResourceWarning>, <Completion: return>, <Completion: reversed>, <Completion: round>, <Completion: RuntimeError>, <Completion: RuntimeWarning>, <Completion: set>, <Completion: setattr>, <Completion: slice>, <Completion: sorted>, <Completion: staticmethod>, <Completion: StopAsyncIteration>, <Completion: StopIteration>, <Completion: str>, <Completion: sum>, <Completion: super>, <Completion: SyntaxError>, <Completion: SyntaxWarning>, <Completion: SystemError>, <Completion: SystemExit>, <Completion: TabError>, <Completion: TimeoutError>, <Completion: True>, <Completion: try>, <Completion: tuple>, <Completion: type>, <Completion: TypeError>, <Completion: UnboundLocalError>, <Completion: UnicodeDecodeError>, <Completion:UnicodeEncodeError>, <Completion: UnicodeError>, <Completion: UnicodeTranslateError>, <Completion: UnicodeWarning>, <Completion: UserWarning>, <Completion: ValueError>, <Completion: vars>, <Completion: Warning>, <Completion: while>, <Completion:with>, <Completion: yield>, <Completion: ZeroDivisionError>, <Completion: zip>, <Completion: __build_class__>, <Completion: __debug__>, <Completion: __doc__>, <Completion: __file__>, <Completion: __import__>, <Completion: __loader__>, <Completion: __name__>, <Completion: __package__>, <Completion: __spec__>]

  6. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Nilesh Kevlani (@njkevlani) on July 27, 2017 20:47

    out put for
    print(jedi.Script("import cv2\ncv2.").completions())
    is attached
    out.txt

  7. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Bob (@fluxin) on July 29, 2017 12:25

    Same issue here, same completions.

  8. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Siddhartha Gandhi (@gandhis1) on July 29, 2017 15:33

    Since the completions aren't correct that means it's a Jedi issue, no? Post this in that repo.

  9. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Nilesh Kevlani (@njkevlani) on July 29, 2017 15:49

    Siddhartha Gandhi (@gandhis1), in my last post,
    "
    out put for
    print(jedi.Script("import cv2\ncv2.").completions())
    is attached
    out.txt
    "
    out.txt contains correct completions.

  10. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From wkema on November 5, 2017 6:55

    manually setting "jedi path" to the newest release of jedi (0.11.0) locally solves the cv2 problem. But some other features of the extension will be lose like "go to definition" etc. hmmm....

  11. 18 remaining items

  12. DonJayamanne commented on Feb 26, 2018

    @DonJayamanne
    Author

    anribras Guillermo Barbadillo (@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.

  13. denck007 commented on Feb 27, 2018

    @denck007

    The insiders build of the extension works! Code completion for opencv works now! Thank you Don Jayamanne (@DonJayamanne)

  14. tzing commented on Feb 27, 2018

    @tzing

    +1 the insiders build works
    python 3.6.4
    vscode 1.20.1
    archlinux

  15. DonJayamanne commented on Feb 27, 2018

    @DonJayamanne
    Author

    Thanks guys

  16. ironbar commented on Feb 27, 2018

    @ironbar

    I confirm that it works also for python 2.7
    Thanks for your work!

  17. anribras commented on Feb 27, 2018

    @anribras
  18. stevecfloat commented on Mar 3, 2018

    @stevecfloat

    Insiders build .vsix installed and confirmed working with autocompletion for OpenCV-Python.
    Thank You Don Jayamanne (@DonJayamanne)

  19. zchrissirhcz commented on May 19, 2018

    @zchrissirhcz

    stevecfloat How long does it take to compile the vscode python extension on your machine? I've in the second task for almost 2 hours. Could you guys provide your .vsix file please?

  20. locked as resolved and limited conversation to collaborators on May 22, 2018
  21. brettcannon commented on May 22, 2018

    @brettcannon
    Member

    Zhuo Zhang (@zchrissirhcz) it shouldn't take that long. You can always download a development build of the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions