-1

Probably simple error, but my current Visual Studio project is not able to run debug Python interactive. I had this working with same computer and environment before.

I have Python project open in Visual Studio, test with new module1.py file in project, the contents of file is just print('test output to console').

Python 3.7 showing as virtual environment in the project still, as previously, I click Debug -> Execute File in Python Interactive.

Then it fails to run after not finding Traceback file, trace as follows:

Resetting Python state.
Running C:\Users\will_\Documents\Repos\Facebook1\FacebookNonConfVersion\module1.py
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\ptvsd_repl_launcher.py", line 27, in <module>
    import traceback
ModuleNotFoundError: No module named 'traceback'
The interactive Python process has exited.

Also, after activating this project's Python 3.7 virtual environment in command prompt, this module1.py file will still run, so I assume that the virtual environment is not corrupted, and this error is something to do with my VS setup, but I may be wrong.

I'm probably missing something obvious.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Will Croxford
  • 457
  • 2
  • 7
  • 21

1 Answers1

0

OK, the key info I didn't mention (if I knew to mention it, probably wouldn't have asked the question) was that I manually renamed both the Visual Studio solution and project files in Windows File Explorer, after copying the whole solution first to back it up.

If anyone else sees this, I fixed the problem by just creating new solution and project in Visual Studio, re-installing packages I needed in virtual environment in the new solution, and copying over the Python files.

I now appreciate the VS solution file is actually a very small (1kb in my case) text file with config settings including some long hex numbers, and just renaming it in Windows file explorer will probably (certainly?) mess up all the references, and prevent it from running (actually in console mine couldn't find the openpyxl package I had installed in virtual environment, so couldn't run the main Python file, I guess because of this).

Related to this problem is canonical looking question: Proper way to rename solution (and directories) in Visual Studio

Will Croxford
  • 457
  • 2
  • 7
  • 21