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

Debugger triggers ImportError when numpy is imported #13500

Closed
swayson opened this issue Aug 18, 2020 · 6 comments
Closed

Debugger triggers ImportError when numpy is imported #13500

swayson opened this issue Aug 18, 2020 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@swayson
Copy link

swayson commented Aug 18, 2020

Environment data

  • VS Code version: 1.47
  • Extension version (available under the Extensions sidebar): v2020.8.101144
  • OS and version: Windows 10 18362.30
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.6, 3.7, MiniConda 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: numpy 1.18, numpy 1.19
  • Relevant/affected Python-related VS Code extensions and their versions: Python v2020.8.101144
  • Value of the python.languageServer setting: XXX
Name: Python
Id: ms-python.python
Description: Linting, Debugging (multi-threaded, remote), Intellisense, Jupyter Notebooks, code formatting, refactoring, unit tests, snippets, and more.
Version: 2020.8.101144
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Being able to use the step-through debugger.

Actual behaviour

Any import of numpy results in an import Error. However, if the script is run from the terminal, this numpy import error does not occur. In other words, the issue is specific to the VS Code Python Debugger.

Exception has occurred: ImportError


IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "C:\Users\potassium\Miniconda3\envs\test_numpy37\python.exe"
  * The NumPy version is: "1.18.5"

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

import numpy will trigger the error when a Python module is executed with "Start Debugging".

I tried numpy 1.18.5 and 1.19. I reinstalled VS Code and Miniconda. Problem still remains. I didn't have this issue before.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@swayson swayson added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Aug 18, 2020
@karrtikr karrtikr removed the triage-needed Needs assignment to the proper sub-team label Aug 18, 2020
@karrtikr
Copy link

We just want to quickly acknowledge that we have received the issue and will be looking into it soon.

@swayson
Copy link
Author

swayson commented Aug 20, 2020

Thanks @karrtikr appreciate it. Shout if you need more info from my end.

@karrtikr
Copy link

It looks like the code is not running within an activated conda environment when debugging it. Can you try this?

  1. Anaconda prompt and cd to your workspace.
  2. Activate the environment using conda activate
  3. Start VS Code using code .

related #10626

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Aug 20, 2020
@swayson
Copy link
Author

swayson commented Aug 20, 2020

hi @karrtikr I followed your instructions and the debugger works when I use the Anaconda Prompt to launch code.

@swayson
Copy link
Author

swayson commented Aug 20, 2020

Thanks I can work with this. Is this the a temporary workaround or are you still figuring out another way to address this more permanently?

@karrtikr
Copy link

Great, conda activation is a tricky one to get right for us, but we have plans to fix it, until then please use the workaround. Closing in favor of #5344

@ghost ghost removed the triage label Aug 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants