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?
I'm pretty new so I'm probably making a really easy mistake. Would really appreciate it if you could help. :)
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.
Check the installation package:
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)
Related
im very new to code in general so this could be a stupid beginner problem ive searched for things but i couldnt find something useful for me
under Problems is the message: Import "pygame" could not be resolved
You can use pip show pygame to view the package installed location.
And check whether the installation location is consistent with the version corresponding to the selected Python interpreter.
There are two ways to solve this problem:
"ctrl+shift+P" and change the python interpreter.
If you don't want to change the interpreter, you can use pip -t flodername pygame #flodername is your used python package location. Install the pygame package to the specified directory
First, try restarting your computer or vs code
Use this command in your vs code terminal if the above doesn't work:
pip uninstall pygame
Then reinstall pygame using:
pip install pygame
If this also does not work then follow these steps:
Go to the scripts folder of python.
Open command prompt or Powershell in the script folder.
Use this:
C:\python34\scripts> python -m pip install pygame
Done
As an Anaconda user, I found my packages were being installed to C:\Users\YOUR_USERNAME\anaconda3\Lib\site-packages, which Visual Studio Code was not picking up on.
With the Pylance extension installed, open Settings (File > Preferences > Settings, or Ctrl+,)
At the top, beside Workspace, choose User
Under Extensions > Pylance, scroll until you find Python › Analysis: Extra Paths and select Add item.
Type in the path to which packages are being stored (in this case, C:\Users\YOUR_USERNAME\anaconda3\Lib\site-packages)
Click OK and after a couple moments, you should see something like the below image (i.e, the path is included in the list of paths).
Finally, your Python file should have picked up on the changes, but if not, reload it or VS Code. If nothing else, add another path that packages are being saved to or change your Python Interpreter. Using another virtual environment's interpreter wouldn't be very helpful, after all.
I may be late, but I hope this helped.
I opened command prompt (I'm on Windows) and I typed:
'''none
pip3 install discord
'''
Then it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed)
Then when I opened VSCode up and typed: import discord I got this error message:
"discord" is not accessedPylance
Import "discord" could not be resolvedPylancereportMissingImports
What does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.
check in the bottom left corner of the VS Code window for which version of Python is it using. This issue usually occurs for me when I’m working in a virtual environment but VS Code is pointing to my global Python installation.
You can change the Python Interpreter in VSCODE to solve this issue.
Open settings in VSCODE by pressing Ctrl + Shift + P. Make sure your .py file is open while doing this step.
Search there Python: Select Interpreter and choose the right version.
Reload VSCODE and see if it works!
Open an integrated Terminal in VS Code,
run python --version, it should be python3.9.7 which is selected as python interpreter and shown in status bar.
run pip show discord to check if its location is \..\python3.9.3\lib\site-packages. If not, reinstall it.
I've downloaded pygame-1.9.1release.tar.gz from the Pygame website. I extracted and installed it and it's working fine in the command line Python interpreter in Terminal (Ubuntu). But I want to install it for some IDE, like PyCharm. How can I do it?
Well, you don't have to download it for PyCharm here. You probably know how it checks your code. Through the interpreter! You don't need to use complex command lines or anything like that. You need to is:
Download the appropriate interpreter with PyGame included
Open your PyCharm IDE (Make sure it is up to date)
Go to File
Press Settings (Or Ctrl + Alt + S)
Double click on the option that looks like Project: Name_of_Project
Click on Project Interpreter
Choose the interpreter you want to use that includes PyGame as a module
Save your options
And you are ready to go! Here is an alternate (I have never done this, please try to test it)
Add PyGame in the same folder as your PyCharm file (Your PyCharm stuff is always in
a specific file placed by you during installation/upgrade)
Please consider putting your PyCharm stuff inside a folder for easy access.
I hope this helps you!
For PyCharm 2017 do the following:
File - Settings
Double click on your project name
Select Project Interpreter
Click on green + button on the right side of the window
Type Pygame in search window
Click Install package.
Not I'm saying that the answers above won't work, but it might be frustrating to a newbie to do command line magic.
If you are using PyCharm and you are on a Windows 10 machine use the following instructions:
Click on the Windows start menu and type cmd and click on the Command Prompt icon.
Use the command pushd to navigate to your PyCharm project which should be located in your user folder on the C:\ drive. Example: C:\Users\username\PycharmProjects\project name\venv\Scripts.
(If you are unsure go to the settings within PyCharm and navigate to the Python Interpreter settings. This should show you the file path for the interpreter that your project is using. Credit to Anthony Pham for instructions to navigate to interpreter settings.)
HINT: Use copy and paste in the command prompt to paste in the file path.
Use the command pip install pygame and the pip program will handle the rest for you.
Restart you Pycharm and you should now be able to import pygame
Hope this helps. I had a fun time trying to find out the correct way to get it installed, so hopefully this helps someone out in the future.
I just figured it out!
Put the .whl file in C:\Program Files\Anaconda3
While in the folder, click on the blue File tab in the upper left corner of the Window Explorer (assuming you're using Windows)
Click on Open Windows PowerShell as administrator
Write or just copy and paste: py -m pip install pygame
It should start installing
Done!
I hope it works for you. I know it did for me.
I already had pygame installed with python38-32
since its working just fine with it. I used this version of python us my project interpreter.
1.File -settings
2.according to your settings look for project interpreter
3.click on your current project interpreter and click on the add symbol
4.choose system interpreter
5.select the python version thats works with pygame for you
6.Note: some versions of pygame don't work with some versions of python be sure
of what are you doing.
7.hope it works.
Hi I'm really new on the programming. I am using VS Code with Anaconda interpreter:
Here
I am using Windows 10
I want to import "requests" module on my VS Code. I opened cmd and wrote "pip3 install requests" but it told me "Requirment already satisfied:" etc... Then I tried to download with Anaconda. I opened my cmd and wrote "conda install requests" and I downloaded.
Then I wrote this code to try module: Here
But I received an error in VS Code like that: Here
What can I do to solve this problem? Thank you so much for your answers. (By the way, sorry for my bad English :D I hope I explained my problem.)
Click in bottom left cornet in VS code on (Python <Version>) and then choose the python version that in your system.
I have just found the answer. In VS Code, I open powershell and write "py (filename).py". But just now, I tried to click top-right button which name is "Run Python File in Terminal" (green button). Then code executed successfully. I didn't take an error.
Check the following prospects in vscode with python extension:
When selecting interpreter, press ctrl+shift+' to open a new integrated terminal. If you selected base:conda environment, the terminal should be like this:
Then use pip list to show modules you've installed, if module requests not there, type commands pip install requestsin the terminal;
click then create a launch.json file, select Python File. This creates and opens a launch.json. You can close it or add configurations you want. More guidance about debug configurations you can reference: Python debug configurations in Visual Studio Code. Press F5 to run your code.
Just make sure the module installation is in the same environment as interpreter you've selected.
I have Eclipse working and am working uder the Pydev plugin, and I need some help with pygame. I'm on a mac and have managed to get pygame working for python 3.3 using homebrew, and pydev's causing me some trouble. The libraries don't seem to be recognized. I can use pygame as needed, doing things like
import pygame
and
pygame.init()
without problem, but Eclipse doesn't recognize the modules and says things like
unresolved import: pygame
Again, I think the issue here is Eclipse not having access to the pygame libraries. How do I fix this?
Windows > Preferences > pydev
look for the python interpreter line
on the libraries tab, click new folder and add the pygame folder path, apply and you're done
NOTE : make sure to use python 3.x as the project interpreter
I wasted forever trying to get this to work as well. I eventually found these steps (you don't need them all, just part of my struggles are shared here).
in Python Shell:
import sys
print (sys.path)
I noticed that no PYGAME appeared in path. Eventually I GAVE UP on the .exe binaries and was told to use .WHL files and Python PIP to install. But was told NOT VALID wheel file.
What EVENTUALLY WORKED was (in windows, but similar should work in other OS's) to run Command Prompt as Administrator (just to be sure). Maybe the solution will also work in other OS's (you'd have to try).
From C:\> I Changed Dir to my Python.exe (or the python program itself).
From my python directory in command prompt I typed the following (Like I would in a linux apt-get install command):
python.exe -m pip install pygame
Shortly after, ther ewere hash marks ##### indicating a download was taking place (linux type progress bar in shell).
In ECLIPSE without ever changing the Libraries folder to include PyGame folders I was able to run a sample Python PYGAME script sample (I got a white screen but haven't gone further yet). I was just happy to not have to see the trace back error message.
Just thought this would help someone.
python.exe -m pip install pygame [Worked perfectly]