#🔒 ModuleNotFoundError :(

75 messages · Page 1 of 1 (latest)

spiral bone
#

import requests
ModuleNotFoundError: No module named 'requests'
(.env) sh-5.2$ in 6 lines I'm noob I don't what's wrong with this can someone guide me please?

stray zodiacBOT
#

@spiral bone

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.

zinc roost
#

!code

stray zodiacBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

zinc roost
#

don't post screenshot of code

#

if the module is not found, you need to pip install it

spiral bone
#

Several times.

#

But i don't know why it's still errors in there

#

I've even downloaded the requirements.

zinc roost
#

do py -0p in your terminal

opaque jay
spiral bone
opaque jay
#

Can you do pip --version in that same terminal?

spiral bone
opaque jay
#

...... okay I am now a bit concerned about where this venv was created from. Can you run this last command for me:
python -m pip --version

spiral bone
opaque jay
#

So when you pasted the results of pip list before, that was in a different terminal outside of VSCode?

opaque jay
#

In the VSCode terminal, can you run this: .env/bin/activate and then do pip --version?

opaque jay
spiral bone
#

(.env) sh-5.2$ .env/bin/activate
sh: .env/bin/activate: Permission denied
(.env) sh-5.2$

spiral bone
# opaque jay in that other terminal, can you do `pip --version`?

Traceback (most recent call last):
File "/var/home/bazzite/چت بات/.env/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
(.env) sh-5.2$ python -m pip --version
/var/home/bazzite/چت بات/.env/bin/python: No module named pip
(.env) sh-5.2$

opaque jay
spiral bone
spiral bone
#

Or vs code

opaque jay
#

Can you fully restart VSCode, open a terminal within VSCode, do .env/bin/activate, and then do pip --version?

#

Also, I think I know the answer to this question, but to create the venv did you install Python separately or is the venv based off of what shipped with your OS?

spiral bone
opaque jay
#

Yeah, fully close all processes of it and then re-open it

spiral bone
opaque jay
#

The weird part here is VSCode is not picking up your env's site-packages folder which does have pip....

spiral bone
#

I think I'm cooked right?

opaque jay
#

Can you take a screenshot of the bottom right hand corner of VSCode? I want to see what interpreter it's using

spiral bone
#

How should I fix it?

opaque jay
#

screenshot first and then we can figure out to go about it

opaque jay
#

Wait.

#

3.12?

spiral bone
#

Ya I think

opaque jay
#

Can you click that and take a screenshot of what pops up near the top of the screen?

opaque jay
opaque jay
spiral bone
#

Ya

opaque jay
#

Are you sure you're clicking on the right thing? Because that isn't what should be popping up

#

You should see something like this instead

spiral bone
#

No just this thing pops up

#

I clicked on. Env 3.12.11 and this pops up

opaque jay
#

Okay, can you go to settings and open up the command palette instead?

opaque jay
#

Type: "Select Python Interpreter" and you should see something pop up similar to that

spiral bone
#

Now I see the python version list

opaque jay
#

Cool, can you share what pops up?

spiral bone
opaque jay
#

Have you ever created multiple venvs in the same folder?

#

I am not concerned somehow have a clashing 3.12 and 3.13 living in the same venv

opaque jay
#

Okay, so that's the issue.

spiral bone
#

Both in a folder Named چت بات

opaque jay
#

Venvs should be project specific. Each project should get its own folder and 2 venvs with the same name should not be created in the same spot.

spiral bone
#

Oh..

So I have to delete the folder then create a new one?

opaque jay
#

I would do this:

  • Create a new folder for your project
  • Create a venv in that folder and move your code over
  • Activate the venv in that folder and install the modules you need there

If you want more projects int he future, they get their own separate folders with their own separate venvs

spiral bone
#

I have to install python in new folder?

#

Thanks, buddy, you saved me from a several hour long nightmare ❤️‍🩹

opaque jay
#

Not necessarily, just create a new venv and that should hopefully be fine

spiral bone
#

Have a great night, bye

stray zodiacBOT
#
Python help channel closed using Discord native close action

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.