#๐Ÿ”’ interpreter set but module not found even though installed

57 messages ยท Page 1 of 1 (latest)

small gull
#

as the title suggests, I am having issues runnig my code, I keep getting a module not found error.

I did some research and it seems the issue would be a discrepancy between the interpreter and the venv pythonn version, for which the dependencies are installed for.

with the venv activated I run a which python command and the response is

python: aliased to /usr/bin/python3

I checked my .zsrhc file and there is an entry there for alias python=/usr/bin/python3

I try to run my code using python run.py , where run.py is considered my "main" file.

when i do this I get the module not found error.

when I try to use python3 run.py as is the aliased python, from the which command.

The response I get in this scenario is that the computer asks me to load some lower level dependencies.

hushed joltBOT
#

@small gull

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.

dreamy brook
#

iirc venv should override aliases

#

how did you activate the venv, what does your terminal look like?

small gull
#

its a zsh terminal

#

i am kind of noob, but not really, but i essentially navigate to the /venv/bin folder

#

then run it using source activate

#

then traverse up to my main level

dreamy brook
#

and does your terminal say (venv) at the beginning of each line?

small gull
#

yup

#

it's activated

dreamy brook
#

and when you run source python it shows that alias?

small gull
#

i never ran the source python command

#

i get back a long resposne

dreamy brook
#

sorry

#

i meant which python

small gull
#

python: aliased to /usr/bin/python3

dreamy brook
#

you're running your code using the global python installation, but your packages are installed in the venv (or the other way around)

#

if your python alias is fixed, then you'll be running code and installing packages in the same environment

small gull
#

hmm i sort of understand

#

didnt realize i was using global package

small gull
dreamy brook
#

Personally I would just remove the alias from zshrc

small gull
#

wont that screw up other scripts

dreamy brook
#

if you want to use the global python, just use python3 instead of python

dreamy brook
#

.zshrc is only loaded when you launch the zsh terminal

small gull
dreamy brook
#

you wouldn't

#

it is

small gull
#

alright lemme remove the alias

dreamy brook
#

that's why you don't really need an alias which makes it easier to use

#

you do have to use the global installation to create a virtual environment, though python3 -m venv venv

small gull
#

can i copy pasta some of my file for review

dreamy brook
#

maybe just start another post if you've fixed this problem

small gull
small gull
#

i also used brew to install it

#

wondering if I should remove other aliases

dreamy brook
#

probably not

small gull
#

ok deleted aliases lets see

dreamy brook
#

just be aware that your aliases take priority over whatever is happening in the venv

#

fyi you're gonna need to close and re-open zsh to refresh your .zshrc

small gull
#

I ran source ~/.zshrc

#

is that diff than what you're suggesting

dreamy brook
#

that won't delete an alias which was already created earlier

#

afaik

small gull
#

alright so close and restart term

#

welp

#

now the homebrew alias is giving me an error

#

zsh: no such file or directory: /opt/homebrew/bin/python3

#

might need to delete that one too, idk seems sus

#

analysis paralysis

#

which python points to the alias

hushed joltBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.