0

This is a follow-up to the following question VSCode Python version defaults to 2.7 in the integrated terminal no matter what I do. I would have left it as a comment, but I don't have enough reputation.

I am running VSCode 1.50.1 on macOS High Sierra 10.13.6.

I had a problem where the version of Python on integrated terminal defaulted to 2.7.16, even though the default terminal was running 3.7.1. I followed the instructions in the above question and low-and-behold, I get the following output:

bash-3.2$ python -V
Python 3.7.1

However, I cannot see my home directory as a prompt in my terminal. I looked at the following answer (VSCode terminal not showing current folder) but it suggests adding "terminal.integrated.shellArgs.osx": ["-l"] into settings.json, which reverts back to using Python 2.

Is there a way of changing the prompt to the home directory, whilst stilling using Python 3?

EDIT: I have tried selecting Python: Select Interpreter from the Command Palette, but the terminal still runs Python 2, even though the bottom left corner say I'm using Python 3.7 virtual environment.

Lewis T.
  • 1
  • 2

3 Answers3

0

When your python reverts back to 2 you can change it inside of VSCode. Go to the command palette. This is done by clicking on View -> Command Palette in the menu bar. Once you have the command palette open find the command: Python: Select Interpreter. This will allow you to select one of the existing Pythons. There you can select Python 3.7 or 3.8. This may require virtual environments but I assume you are already using them.

Natsfan
  • 4,093
  • 3
  • 22
  • 29
  • Thanks for your suggestion. I have tried it and it uses Python 2 in the terminal, even though it says Python 3.7 on the bottom left corner. – Lewis T. Oct 19 '20 at 13:36
0

I managed to fix this in the settings: by turning terminal.integrated.inheritEnv to false.

You can doing this on MacOS by clicking on Code -> Preferences -> Settings. In the search bar, search for terminal.integrated.inheritEnv and untick the box.

Lewis T.
  • 1
  • 2
0

Add export PS1="\u@\h:\w\\$" to your .bashrc file in your home directory (or make the .bashrc file if you need to). Then source .bashrc or relaunch your console and it should be in order.

\u = user \h = host \w = working directory (full path)

You can also add PROMPT_DIRTRIM=1 or any other integer for how many directories deep you want to display.