Unable to run python3 debugger in VSCode - python-3.x

Issue
Currently I'm unable to debug python3 scripts in VSCode. Normally, after clicking "Start debugging" with the python3 interpreter set the VSCode terminal pops up and initiates the script. Now, nothing pops up, but when I look at the "Output" section I do see output assuming from the python extension after I click "Start debugging".
If I switch the interpreter to python 2.7 it works, but 3.7 does not. I reinstalled the python vscode extension and confirmed that the path to the python3 bin file is correct.
Output
> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 ~/.vscode/extensions/ms-python.python-2019.10.41019/pythonFiles/ptvsd_folder_name.py
> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 ~/.vscode/extensions/ms-python.python-2019.10.41019/pythonFiles/ptvsd_folder_name.py
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -c "import sys;print(sys.executable)"
Specifications
VSCode Python Extension
Name: Python
Id: ms-python.python
Description: Linting, Debugging (multi-threaded, remote), Intellisense, Jupyter Notebooks, code formatting, refactoring, unit tests, snippets, and more.
Version: 2019.10.41019
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python
VSCode
Version 1.36.1 (1.36.1)
OS
macOS 10.14.6 (18G4032)

I couldn't determine the cause. So I ended up deleting VSCode as well as removing all traces of python3. Finally, I reinstalled both as well as pylint and the python VSCode extension. This resolved the debugger issue.

Related

PyCharm cannot find gdal libraries when using os system in WSL Ubuntu

The problem is that within the PyCharm editor, the gdal applications (e.g. gdalwarp or gdal_grid https://gdal.org/) cannot be found when using os.system. For example the code:
os.system(f"gdalwarp -t_srs EPSG:27700 {fnc} {tname}")
returns this error message 'sh: 1: gdalwarp: not found'.
I am using PyCharm interpreter with the following settings:
Ubuntu WSL platform
conda environment with gdal libaries installed.
When I run the code from the ubuntu terminal, it does find the gdal libraries. So I don't think the problem is within the conda environment, but there is a problem with PyCharm settings to find the gdal application using os system.
I do not want to change the code, but I would rather figure out the correct PyCharm settings. Any help would be greatly appreciated.

Spyder debugger freezes within Anaconda virtual environment

I'm working with an Anaconda virtual environment, venv, and I'm running Spyder from it.
Whenever I attempt debugging my code, nothing happens. The debugger seems to get stuck in the first line. For example, if I run the debugger on:
import sys
print(sys.executable)
Running in debug mode produces this output on the built-in IPython console:
debugfile('C:/Projects/Myproject/myscript.py', wdir='C:/Projects/Myproject')
> c:\projects\myproject\myscript.py(1)<module>()
----> 1 import sys
2
3 print(sys.executable)
Neither Debugging buttons in Spyder, nor their related shortcuts, seem to do anything. In particular, pressing the Stop button (or hitting CTRL+SHIFT+F12) results in:
--KeyboardInterrupt--
For copying text while debugging, use Ctrl+Shift+C
I have already made some research, and landed on this GitHub issue page, where it is suggested that I should update IPython. I did, with no benefit.
Another suggestion I found in this other GitHub page indicated the problem might be that the wrong executable for Python is run (i.e., that Spyder is running Python from my base Anaconda environment, rather than my venv). I checked, and both are run from the right path:
print(sys.executable)
C:\Anaconda3\envs\venv\python.exe
These are the version of my dependencies.
Spyder version: 5.1.5 None
Python version: 3.7.11 64-bit
Qt version: 5.9.7
PyQt5 version: 5.9.2
IPython 7.31.1
Operating System: Windows 10
I face the same issue, Spyder 5.1.5 debugging does not work in new environments. There is some clash between versions as I understand, but promised that they will deal with the issue in the next version.
Also, this is a reported issues: https://github.com/spyder-ide/spyder/issues/17350
What seems to work for me is to create a new environment but specify the versions like this:
conda create -n your_fancy_env_name -c conda-forge python=3.8.10 spyder=5.1.5

cmd not showing from spyder script

I have a python script that I run using spyder. It execute other scripts with os.system("...").
My problem is that the cmd windows are not poping (the code is executed, but I can't monitor it, eg see print() or errors).
it was working before I updated spyder recently.
I tried unchecking the "Hide command line output windows generated by the subprocess module" in Tools > Preferences > IPython console > Advanced settings > Windows adjustments
but nothing changed. How can I changed that?
Thanks

How to use pip with Visual Studio Code

I have python 3.6 installed, I have a python extension installed on Visual Studio code but I still can't use pip on Visual Studio code. It says it is not a recognised command. Any help please?
Update: I tried installing pip manually but a file in python2.7 keeps stopping. What's bothersome is that I uninstalled python 2.7 ages ago and I've currently removed every folder with it but python-V still says I have python2.7.6 installed.
I'm on windows 10
I found some solution on this website:
https://pip.pypa.io/en/stable/installing/
If you use Visual Studio Code, you can type the following command:
C:\> py -m pip
If everything is alright, you should see the list of commands, which you can use. They are listed in your terminal, as per below.
I also would advise you to check/select the version of Python you are using:
VSCode: There is no Pip installer available in the selected environment
I am pretty sure your problems of VSCode not finding the correct version of Python will be resolved if you add your ( Python 3.6 installation ) location to the system path.

Python version specification in pycharm terminal

In pycharm's built in terminal how can I specify which version of python I want to run? With my standard terminal I can type either 'python' or 'python3' to run 2.7 or 3.5 respectively however when I try this in the pycharm terminal I can still run 2.7 with the 'python' prompt, but the python3 prompt results in a "command not found" error. I'm really new to python, command lines and programming in general so any help would be greatly appreciated.
Pycharm > Settings > Project Interpreter

Resources