Code is working in pyCharm but not in Visual Studio Code

Viewed 1408

I'm pretty noob to coding. I have been coding for about 3 months. I made a program that could automatically enter Zoom class meetings for me. I'm using Pyautogui and Tkinter.

When I run my code in pyCharm, it works properly. The mouse moves automatically and enters the meeting perfectly.

I have tried running the same code in VSCode but it just opens the Zoom application. The mouse doesn't move and it doesn't type the meeting's ID. I'm trying to use VSCode, because I'm trying to learn new languages and start creating different projects.

This is my code for entering the meeting.

def math():
    subprocess.call([ "/usr/bin/open", "/Applications/zoom.us.app" ])

    time.sleep(2)

    join_meeting = pyautogui.locateCenterOnScreen('join.png')
    pyautogui.moveTo(join_meeting)
    pyautogui.click()

    meeting_id = pyautogui.locateCenterOnScreen('meeting.png')
    pyautogui.moveTo(meeting_id)
    pyautogui.click()
    pyautogui.write('...')
    pyautogui.press('enter')

I use Tkinter to make it like some sort of application with buttons that each will take me to a different meeting. My code works properly but not when running it in VSCode, even though the Tkinter window still opens and opens the Zoom application, but doesn't type nor it moves the mouse.

Update: I found I have this version of pip installed in an old version of python interpreter. How can I change this?

enter image description here

I'm pretty new so I'm probably making a really easy mistake. Would really appreciate it if you could help. :)

2 Answers

This most likely is because you have not installed the Pyautogui Module. So, basically, PyCharm was meant only for Python (now supports more languages), so it made sure to install ALL the main packages. However, the Visual Studio Code was not really meant for Python. Therefore, the Visual Studio Code did not install the packages for you. It is simple to get it anyway. If you don't have pip, then you can search "How to install pip." If you have, then do:

pip3 install pyautogui or pip install pyautogui

You could refer to the following methods to check the installation of the module:

The source of pip is consistent with the environment currently selected by VSCode (shown in the lower left corner of VSCode), and the installed package can be used.

Please use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, it will automatically enter the VSCode environment you currently selected (the python interpreter displayed in the lower left corner of VSCode).

You could enter "pip --version" in the VSCode terminal to check the source of the installation tool pip, and the module will be installed here.

enter image description here

Check the installation package:

enter image description here

Reference: Environment in VSCode.

Update:

Please use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, it will automatically enter the currently selected VSCode environment, we can use "pip --version" to check the source of the installation tool, after confirming that they are consistent, use pip to install the module: (pip install pyautogui)

enter image description here

Related