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

Environment gets activated after debugger starts (hence debugging with conda envs fail) #5559

Closed
crackcomm opened this issue May 5, 2019 · 21 comments
Assignees
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@crackcomm
Copy link

Environment data

  • VS Code version: Just updated
  • Extension version (available under the Extensions sidebar): Just updated
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7, Conda3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda

Issue

Use Debug Python: Current File...

> cd ...
[...]
    from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
ImportError: DLL load failed: The specified module could not be found.

>D:/Anaconda3/Scripts/activate
>conda activate base

Terminal stays open so I can click again the play icon and it works because conda activate base activated Python environment just AFTER the debugger FAILED to start.

Thank you.

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label May 5, 2019
@karrtikr
Copy link

karrtikr commented May 14, 2019

Can you please be more clear here. I am not sure I understand the issue here.

Terminal stays open so I can click again the play icon and it works

  • ... what works?
  • Please provide file content, complete exact terminal display (for eg. what does [...] represent in cd ...) and clarify the steps to reproduce.

@karrtikr karrtikr self-assigned this May 14, 2019
@karrtikr karrtikr added info-needed Issue requires more information from poster triage labels May 14, 2019
@ghost ghost removed triage-needed Needs assignment to the proper sub-team labels May 14, 2019
@crackcomm
Copy link
Author

  • ... debugger?
  • Use Debug Python: Current File...

@karrtikr
Copy link

Please fill the issue template and provide the requested information. The issue is not clear.

@crackcomm
Copy link
Author

No, thanks.

@karrtikr
Copy link

Closing this as sufficient clarification info was not provided.

@ghost ghost removed info-needed Issue requires more information from poster triage labels May 15, 2019
@crackcomm

This comment was marked as abuse.

@karrtikr
Copy link

I understand the issue, however i need more info to reproduce this, as I have asked for before.

  • Relevant file content, complete terminal display (for eg. what does [...] represent in cd ...)

@karrtikr karrtikr reopened this May 15, 2019
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label May 15, 2019
@karrtikr karrtikr added info-needed Issue requires more information from poster triage labels May 15, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label May 15, 2019
@crackcomm
Copy link
Author

[...] represents code that was removed.

@karrtikr
Copy link

I understand that. What I am asking is what is the code that was removed? (Leave out personal credentials if you have to)

@crackcomm
Copy link
Author

This code was removed because there is no issue with the code.

The issue is

>D:/Anaconda3/Scripts/activate
>conda activate base

Is executed AFTER execution of the code.

@karrtikr
Copy link

The reason I was asking this is because AFAICS there are cases where it should not matter if it's activated after or not. For eg. this was terminal in my case,
cd [...] && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && C:\ProgramData\Anaconda3\python.exe [...]\ptvsd_launcher.py --default --client --host localhost --port [...]"

Notice this,
C:\ProgramData\Anaconda3\python.exe
The python executable is directly being used here, so it does not matter if environment is activated before or not.

What i wanted to understand was the reason that it mattered in your case (so I can reproduce & confirm it). Regardless, I understand the core issue here.

@crackcomm
Copy link
Author

To replicate use any library that loads DLL for example graphviz, pytorch, tensorflow.

@crackcomm
Copy link
Author

In my example it was matplotlib.

@DonJayamanne
Copy link

DonJayamanne commented May 16, 2019

@crackcomm
Apologies for the confusion, I understand the issue.
Basically the environment is getting activated after the debugger has started.
We'll be tracking this here #4568

@DonJayamanne DonJayamanne added area-debugging needs PR bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster triage labels May 16, 2019
@DonJayamanne
Copy link

DonJayamanne commented May 16, 2019

Solution identified in microsoft/vscode#67692 could fix this.

Updated Solution - Use conda run.

@bryceschober
Copy link

@DonJayamanne Can you clarify your proposed solution of conda run? Are you proposing a modified launch configuration? Could you provide an example?

@DonJayamanne
Copy link

@bryceschober this isn't a change to the launch configuration. Instead of running user code using <python executable> <user code> we'll be using conda run <env name> python <user code>.

@DonJayamanne DonJayamanne changed the title Environment is activated after debugger fails Environment gets activated after debugger starts (hence debugging with conda envs fail) Aug 15, 2019
@AlexH415
Copy link

I seem to have this problem too. I don't understand what is meant by "Instead of running user code using we'll be using conda run python .". Is this a fix I can apply myself now? If so, how do I do it please?

@damdaepark
Copy link

@DonJayamanne You mean this conda run solution will be updated soon?

@DonJayamanne
Copy link

That is the plan.

@kimadeline
Copy link

Closing in favour of #10626

@ghost ghost removed needs PR labels Apr 8, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

8 participants