#๐Ÿ”’ Getting imports to work

63 messages ยท Page 1 of 1 (latest)

velvet silo
#

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?

thin hamletBOT
#

@velvet silo

Python help channel opened

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.

full cloud
shut lichen
velvet silo
full cloud
velvet silo
#

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?

shut lichen
opaque rock
#

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.

velvet silo
#

oh, i found it there

#

it works now, thanks

velvet silo
opaque rock
velvet silo
#

it says "'py' is not recognized as an internal or external command, program or per-lot executable file"

opaque rock
#

Is that in command prompt?

velvet silo
#

yes

opaque rock
#

Humor me and can you try that same command in powershell too?

velvet silo
#

"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"

opaque rock
#

Then also try python -m pip --version

velvet silo
opaque rock
#

Huh, interesting

#

the py install manager doesn't seem to have been installed. Rare but happens

velvet silo
#

huh

opaque rock
#

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

velvet silo
flint violet
opaque rock
opaque rock
# velvet silo

okay you're good, I was worried it would point to a different python install

velvet silo
#

that is a reasonable worry, my python install is kinda wonky

#

i had to uninstall it and install it again to get pip working

flint violet
#

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

velvet silo
#

hm

full cloud
#

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

flint violet
#

Using python naively can have the same effect

full cloud
velvet silo
#

Venvs are something i need to get into

full cloud
#

it is actually quite in-depth

velvet silo
#

Thanks

full cloud
#

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

flint violet
full cloud
untold grotto
#

What does the vscode terminal show when you to run that script?

velvet silo
#

ok, i think i found something

#

there's two python .exes

#

is this normal?

vague epoch
#

Oh yes, yes it was

shut lichen
#

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.

velvet silo
#

hmm

full cloud
# velvet silo 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
velvet silo
#

thanks

full cloud
#

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)

thin hamletBOT
#
Python help channel closed for inactivity

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.