2

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. :)

  • 1
    Please check that the required modules "subprocess" and "pyautogui" in the code have been installed in the currently selected environment of VSCode and try to use the absolute path of the image file or put it in the same folder. – Jill Cheng Nov 24 '20 at 05:07
  • @JillCheng How can I see what environment is being used for VSCode? – Oscar Treviño Nov 25 '20 at 02:19

2 Answers2

1

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

  • I have already install them with pip and still can't get it to work in VSCode. It is really weird because subprocess works fine but pyautogui doesn't. – Oscar Treviño Nov 25 '20 at 02:21
  • hmmm... what python version are you using? –  Nov 25 '20 at 09:06
1

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

Jill Cheng
  • 9,179
  • 1
  • 20
  • 25
  • When I try to check for the pip version I get this error: `Traceback (most recent call last): File "/usr/local/bin/pip", line 6, in from pkg_resources import load_entry_point ImportError: No module named pkg_resources` – Oscar Treviño Nov 25 '20 at 02:48
  • I installed pip again. – Oscar Treviño Nov 25 '20 at 02:56
  • I found that pyautogui is installed in a different environment (Python2.7) than the one that VSCode is using (Python3.9). – Oscar Treviño Nov 25 '20 at 03:00
  • How can I install pyautogui in a specific Python environment? – Oscar Treviño Nov 25 '20 at 03:00
  • Yes, then you can reinstall the required modules in the python3.9 environment. – Jill Cheng Nov 25 '20 at 03:01
  • @Oscar Treviño -You could use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, and it will automatically enter the currently selected VSCode environment.(I updated my answer) – Jill Cheng Nov 25 '20 at 03:09
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/225140/discussion-between-oscar-trevino-and-jill-cheng). – Oscar Treviño Nov 26 '20 at 04:48
  • I have this version of pip and saw that it is installed in another python interpreter... what can I do? _I will post the picture on the question_ – Oscar Treviño Nov 26 '20 at 04:50
  • @Oscar Treviño -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). – Jill Cheng Nov 26 '20 at 04:56