Jump to content

Python project can’t find module if using Python3, but finds it with Python

constantly_confused

Hello all, 

I’m fairly new to Python and am creating a GUI project using customtkinter. I’ve been making good progress and updating the project until recently Python updated and now no longer works. I’m using VSCode to write the project. When I launch the project using <python3 app.py> I get a module not found error, even though it’s been working fine until now and not only it is installed, but I cloned the repo to the project folder as one GitHub thread said to do. If I run <python app.py> it seems to run fine and it doesn’t complain about the module not being there. Why is this, and how do I resolve this? Thanks in advance! 

Link to comment
Share on other sites

Link to post
Share on other sites

33 minutes ago, Slottr said:

Do you have python installed or previous iterations?

I have Python3 installed. Python 3.11 to be specific. I also should’ve specified that this is on a Windows10 machine. 

Link to comment
Share on other sites

Link to post
Share on other sites

if you have both python 2 and python 3 installed they'll use different environments. if you did a "pip install <module>" that'll have installed it under python2, you need a "pip3 install <module>" to have it in the python3 environment.

 

EDIT based on new info: On Windows you always want just "python" unlike linux/mac, no reason to use "python3".

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Kilrah said:

if you have both python 2 and python 3 installed they'll use different environments. if you did a "pip install <module>" that'll have installed it under python2, you need a "pip3 install <module>" to have it in the python3 environment.

 

EDIT based on new info: On Windows you always want just "python" unlike linux/mac, no reason to use "python3".

Oh I didn’t know that. Thank you! I typically run Linux and started my coding journey there but this project will be used on Windows10. In VSCode there’s a play button in the top right to execute the code and that’s what I’ve been using and that tries to use the Python3.11 executable to run the project. Do you happen to know if there’s a way to change that? 

Link to comment
Share on other sites

Link to post
Share on other sites

You should be able to click at the bottom right on the version and select another... But I've never seen a "python3" on Windows that I can remember, so no idea how you even got that.

 

image.png.3dc49e593d566b5f759393bdc08feaea.png

 

When I click play it just uses python.exe.

 

image.png.4ec9cef6247e2d694e3b08346f98f073.png

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

33 minutes ago, Kilrah said:

You should be able to click at the bottom right on the version and select another... But I've never seen a "python3" on Windows that I can remember, so no idea how you even got that.

 

image.png.3dc49e593d566b5f759393bdc08feaea.png

 

When I click play it just uses python.exe.

 

image.png.4ec9cef6247e2d694e3b08346f98f073.png

I think I found my issue. So I originally installed Python3 using winget to help automate the process across desktops (I was using a .ps1 script to install everything). It allows me to select from:

“3.11.4 64-Bit (Microsoft store)” which uses “C:/Users/$USERNAME/AppData/Local/Microsoft/WindowsApps/python3.11.exe”.
When I switch it to “3.11.4 64-Bit” it uses “C:/Users/$USERNAME/AppData/Local/Programs/Python/Python311/python.exe”. 

It must’ve defaulted to the Microsoft store version at some point because now it’s running as expected. Thank you again! The help is greatly appreciated! 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×