I'm trying to install matplotlib and numpy on windows 11, but i'm not sure why they won't get called. The first image is my cmd, saying what i assume means they're installed? My python is installed in Program Files and my installed libraries are in Roaming, which might be part of the issue. Also, my cmd doesn't allow me to use "py" to call python, it has to be "python", so that might be a hint too?
#๐ Getting imports to work
63 messages ยท Page 1 of 1 (latest)
@velvet silo
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
how did you install python?
was it through the microsoft store?
You current pyhton has it installed, by PyLance doesn't know that. It's a separate setting in VSCode somewhere. PyLance is a linter which runs on your code in the editor to mention things which may be dubious.
it was through python.org, i got the installer
i see
in that case you should have py installed and available unless you did something very strange during the installation or went in and uninstalled the python launcher
i'm very bad with this stuff, i get lost even following a wizard
i'm where pylance settings are, what am i looking for?
I don't know. Can you tell it what python instal to make use of?
In the bottom right corner of VSCode, it should tell you what Python version it's looking at. If you click that, you should be able to point it to the correct Python process you're using.
i still wonder about this though
In the terminal (either inside VSCode or not) what is the output of py -0?
it says "'py' is not recognized as an internal or external command, program or per-lot executable file"
Is that in command prompt?
yes
Humor me and can you try that same command in powershell too?
"the term 'py' is not recognized as the name of a cmdlet, function, script file or executable. Confirm the name was written correctly, or if an access path was included, confirm said path is correct and try again"
Then also try python -m pip --version
Huh, interesting
the py install manager doesn't seem to have been installed. Rare but happens
huh
It's not super crucial though... well. I want to check one more thing, just to be super sure
what is the output of pip --version
Isn't it opt-in for 3.12?
Not from my experience, but it's been a hot second
okay you're good, I was worried it would point to a different python install
that is a reasonable worry, my python install is kinda wonky
i had to uninstall it and install it again to get pip working
Give virtual environments a try sometime
pip and python will point to what you mean in the context of a virtual environment, and virtual environments isolate project dependencies on top of it
hm
also, you are doing the right thing by using python -m pip over using pip directly, as using pip directly can more easily get you in trouble with multiple python installations
Using python naively can have the same effect
at least it's the same python that gets the modules installed then
of course, unless venvs are involved, as that can also be a source of this kind of problems unless you understand them and know how to use them properly
Venvs are something i need to get into
this is a very good introduction (and more): https://realpython.com/python-virtual-environments-a-primer/
it is actually quite in-depth
Thanks
and you probably don't need to read all of it if it feels too daunting
better you read some of it, than none of it
What problems arise from using pip and python in the context of an activated virtual environment? If anything it means you won't be using anything outside that context so it's not like there'll be a confusion
i wasn't talking of an activated venv, i meant if you forget to activate the venv when installing modules but have it active when trying to use them, or the other way around
it wasn't about python and pip, it was just that involving venvs can introduce more complexity for those who don't know them yet, even though using venvs are best practice
What does the vscode terminal show when you to run that script?
You've never started your venv, no?
Was that ever mentioned in this thread already?
Oh yes, yes it was
It can be, but I think this is more misfortune than planning.
If you have several pythons around eg 3.10 and 3.12 and 3.13 (eg for compatibility with particular packages) you'd have multiple python.exe instances, one per install.
And there's one per venv also (a venv is a thin wrapper over one of the main installs).
I suspect you might have the Windows Store and the python.org pythons installed. I gather (I'm not a windows person) that the python.org one is to be preferred.
And I suspect the two installs are what led to your environment using one (the python.org one, based on the above) and pylance using the other. And thus the disagreement about what packages had been installed, as that is per-python.
hmm
i think @shut lichen is correct about there being one python installed via the windows store, i would generally recommend uninstalling that one to fix possible future issues it might cause down the road
even though, doing so might create some issues right now if it's in use somewhere
@velvet silo if (and only if) you want to remove any and all python installations that comes from the windows store you can run this command in powershell
Get-AppxPackage -Name "PythonSoftwareFoundation.Python.3.*" | Remove-AppxPackage
thanks
if you only want to see what it lists you can simply run the command without the | Remove-AppxPackage (before you have run it with that part, after that it's too late to inspect the list as the packages won't be left on the system anymore)
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.