R
Railway•11mo ago
rokochi

Error with discord bot using go and python

I am new to asking questions in a place like this, so please forgive me if there are any problems I have created a discord bot that uses Go as its main language and responds with openai api(python). When I run it, I get an error that python3 not found (I modified the code to say "python" and get the same error). How can this be resolved? [error message] Command failed: exit status 127, Stderr: /bin/sh: 1: python3: not found
Solution:
this is the golang package I've used for a chatgpt telegram bot https://github.com/ayush6624/go-chatgpt...
Jump to solution
37 Replies
Percy
Percy•11mo ago
Project ID: N/A
rokochi
rokochi•11mo ago
N/A
rokochi
rokochi•11mo ago
Adam
Adam•11mo ago
Add python to a nixpacks.toml as a provider https://nixpacks.com/docs/configuration/file
Configuration File Reference | Nixpacks
App source + Nix packages + Docker = Image
Brody
Brody•11mo ago
also golang has a good openapi package
rokochi
rokochi•11mo ago
Thank you for your reply. Create a file called "nixpacks.toml", providers = ['...' , 'python'] I tried typing it in, but I still get the same error
Adam
Adam•11mo ago
What directory is the file in? Please share your repo if possible
rokochi
rokochi•11mo ago
Oh, really? Then maybe it is better that way. I'm trying to replace the bot I've been creating all in python with go...
Brody
Brody•11mo ago
that's very admirable
rokochi
rokochi•11mo ago
It's a private repository, but it's not open to the public, so it's fine if you want to show it to others. I don't know how to do this hehe(???)
Brody
Brody•11mo ago
adding python to the providers wouldn't work, nixpacks runs your go app in a slim image that only copy's over the contents of the repo, leaving out python
Adam
Adam•11mo ago
Ah didn't know that. This error in js is fixed with the nixpacks file
Brody
Brody•11mo ago
golang's provider is special
Adam
Adam•11mo ago
I trust Brody on the Go side, if they say that Go works for the bot then Go works
Brody
Brody•11mo ago
and as aleks has told me before, you'd actually wanna add python(38/310/311) as a nixPkgs instead of a provider we can get it to stop running your go app in a slim image if youd like to use python for the time being roko?
rokochi
rokochi•11mo ago
To be honest, I was motivated to try a statically typed language because I often fell down with python, and I would be happy if I could think in the direction of eradicating python in my programs if possible (is this the answer?)
Brody
Brody•11mo ago
hell yeah I love to hear that
rokochi
rokochi•11mo ago
By the way, I tried to install python in a dockerfile earlier and it looked like I could do it, so can I do it in that direction? I thought so, but I didn't understand the specification of dockerfile, so I was dreary(?)
Brody
Brody•11mo ago
you totally could do that, but I recommend sticking with nixpacks unless you have a decent reason to not want to use it
rokochi
rokochi•11mo ago
Well, but I'll go in this direction for now "golang has a good openapi package" ok, thanks
Brody
Brody•11mo ago
also you can return more than one value from a go function, so you'd want to have the return type of the function be (string, error) so when there's an error you can do a return "", err
rokochi
rokochi•11mo ago
Oh, I knew it. Today is actually the first time I've touched golang, and I'm writing code while talking to chatgpt. But I had a sneaking suspicion that I could do something like you talk about while writing lol
Brody
Brody•11mo ago
I assume the python script is talking to chatgpt right?
rokochi
rokochi•11mo ago
yes, I am building a bot using openai api, talking to the web version of chatgpt
Solution
Brody
Brody•11mo ago
this is the golang package I've used for a chatgpt telegram bot https://github.com/ayush6624/go-chatgpt
rokochi
rokochi•11mo ago
you might be cooldoge
Brody
Brody•11mo ago
I just really like go 🙂
rokochi
rokochi•11mo ago
I"ll try this for now. Thanks a lot. I'll close this thread
Brody
Brody•11mo ago
no need to close I will just simply mark as solved
Adam
Adam•11mo ago
You can also do this with python Multiple returns are returned as a tuple which you can access the same way I won't stand for this python slander
Brody
Brody•11mo ago
haha I didn't say you can't do it with python, I only said that because the go function they showed was a single return value
Adam
Adam•11mo ago
<:ross_gun:786867306192961576>
Brody
Brody•11mo ago
python is king, he says nervously
rokochi
rokochi•11mo ago
The package was successfully completed using the previously mentioned package! Thank you so much
Brody
Brody•11mo ago
no problem!
rokochi
rokochi•11mo ago
I personally just have a piece of junk brain that makes more mistakes with dynamic typing... sorry if I offended you
Brody
Brody•11mo ago
no worries you didnt say anything bad at all, im the same way, i work better with go then i would python or javascript