#๐Ÿ”’ I need help on import "request" could not be resolved from source.

38 messages ยท Page 1 of 1 (latest)

leaden turtleBOT
#

@hollow cobalt

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.

minor nymph
#

requests is a thrid party package (not part of the stdlib - "standard library", which comes with Python). You need to install it.

The command: python3 -m pip install requests
should do that, run in the terminal window at the bottom of your VSCode window. If you're on Windows, say py instead of python3, I think.

hollow cobalt
#

okey letme try

#

i did it and it succesfly dowlanded but the problem is still there

signal fractal
#

The error you see in that screenshot is specific to VS Code and the Pylance extension, not directly related to Python.
Pylance is saying one of two things:

  • The module is not installed in the environment it's looking at.
  • Pylance is looking at the wrong environment.
#

Once VS Code has the right environment selected, then Pylance will be able to read the packages you've pip-installed and show intellisense completions.

hollow cobalt
#

which one i have to select on here

signal fractal
#

Probably the first one, the .venv?

hollow cobalt
#

letme try

#

uh okay it solved i did on 3rd

#

god bless you guys

#

thanks again

#

and i have 1 more question can i run my code on microsft excel? like if i type the token and discord channel and what i want to sent in that excel

#

is it possible to do? or i just have to do in vsc

signal fractal
#

Why would you want to use Excel as an input for a Discord bot?
Environment variables would be simpler. Such as with:

#

!pypi python-dotenv

leaden turtleBOT
#

Read key-value pairs from a .env file and set them as environment variables

Released on <t:1705991580:D>.

signal fractal
#

mini spammer
Oh, that's why. Probably shouldn't be doing that, regardless.

hollow cobalt
#

i will use it on my server not for disturbing anyone

#

i play 1 game and there is items i want to sell , and i wanted to spam a channel like 2 per hours like sell item at blablabla

signal fractal
# leaden turtle

Sounds like you are making a cron job with a notification, then.
Anyway, env variables would be the simplest means to authenticate the bot and your chosen server without exposing the token in a github repo, for example (as long as you don't commit the .env file)

hollow cobalt
#

not with bot with discord token is it possible?

signal fractal
#

You would use discord token to authenticate a bot account, yes.

hollow cobalt
#

okey can i show you what i type on the vsc and if you know about that can you tell its normal or not?

#

there is not much turkish guide on youtube with that conent so i wanted to get help from servers

signal fractal
#

So you're asking, essentially, to use some token from Discord to make a POST request that sends a message to your given server?
I mean, you could just use a webhook and send messages to it, then.

hollow cobalt
#

oh can i?

signal fractal
#

Create the webhook within the server channel, copy that URL, and play around with POSTing to it from your own app.

hollow cobalt
#

oh i see know i wrote you wrong its not my discord channel its discord channel own by a the game i play im sorry i wrote wrong my english is not enough

signal fractal
#

If you're asking to send messages to a channel on a server you don't own, you might ask them to create a webhook for you.
Otherwise, no. Spamming messages in this way would probably violate Discord Terms of Service.

hollow cobalt
#

oof

#

there is no way you can help for that?

hollow cobalt
#

@signal fractal

leaden turtleBOT
#
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.