Running Python in Visual Studio Community 2022

mauede 221 Reputation points
2023-07-10T16:30:27.2366667+00:00

My Visual Studio installation is supporting Python.

I started a new VS project for Python

VS seems to come with a very old Python version (2.7.xxx)

How can I change VS Python version?

I downloaded a Python example and pasted into VS editor.

It is an example that uses some VTK primitives. It does not run as expected.

Somehow I have to tell VS where to find the VYK primitives.

I right-clicked on the new project --> Properties but I cannot see how to tell VS to add an external library for Python.

I tried to set up Python environment but VS does not connect it.

I would greatly appreciate some guidelines possibly with examples.

Thank you so much

Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2023-07-11T07:34:25.3033333+00:00

    Hello @mauede ,

    Welcome to Microsoft Q&A forum.

    You can click View => Other Windows => Python Environments to open Python Environments window and check or select the detected/installed Python environment.

    If you want to install another version of Python, you can download it separately from official website: Python. Choose the correct version that you want especially 32 bit or 64 bit. Double click the setup file and wait for it finishes installing, remember to select Add to Path option when installing it. After that VS should automatically detect it and show the available Python in Python environment.

    You may use following code to add an external library.

    import sys
    sys.path.append(package_path)
    import package
    

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.