How to properly set up Python 3.9.2 with VS Code on a Mac?

Viewed 805

I am a complete newbie in programming so I enrolled in a course online to help me learn Python. To start the course I need to set up the latest version of Python and VS code editor. I did install Python on my Mac and I had VS Code from before but it looks like I am missing parts of the set up on the VS Code or Python side that I cannot pinpoint and I need help.

After I ran a basic Python command all I get is the below error. Any thoughts on what I miss in the setup?

This is the error I get - "Missing docstring in public module pydocstyle(D100)"

2 Answers

Based on the information you provided, I reproduced this problem:

enter image description here

This does not mean that there is an error in the code. It is a "code specification" suggestion provided by the Python code analysis tool "pydocstyle" (which is a kind of "Linting"). This information does not affect the operation of the code. Of course, we can also Improve the code specification, add "docstring" at the beginning of the code (for some instructions in the code, and so on.):

For example: Add """This is an output statement.""" at the beginning of the code.

enter image description here

Reference: Linting_pydocstyle in VS Code.

Setting up VS Code with Conda Python Environment

  1. Install conda (Anaconda/Miniconda).

    • I would suggest you to install Miniconda (much smaller memory footprint).
  2. Create a NEW python environment.

    • Run the following from anaconda prompt (windows) or terminal (mac/linux)

    Create the env: conda create -n py39_env python=3.9.2 -c conda-forge anaconda default. Activating env: conda activate py39_env (windows/mac/linux) for conda 4.6 and later versions. For versions prior to 4.6 see here: conda environment management

  3. Install VS Code. download VS Code

  4. Setup VS Code.

    • Use the .vscode/settings.json file in your project-root-directory to define "PythonPath" variable.
      • What is/are your environment python-executable path(s)?

        Run command conda env list in anaconda prompt(windows) or terminal (mac/linux) and make note of the python-executable paths.

      • Open/create .vscode/settings.json file in your project's root folder.

      • Add a key-value pair to the JSON file.

        // file: .vscode/settings.json
        {
           "PythonPath": "your/path/to/python-executable/goes/here"
        }
        

Alternatively, for setting up VS Code, you could follow this: Python path in VSCode.

Related