I'm trying to create my first Reddit bot using the praw package. I'm coding in Pydev for Eclipse.
I'm getting an error that I can't figure out how to resolve. When defining an instance of Reddit, I'm using this line of code:
reddit = praw.Reddit('bot1')
That's the format I have seen in a bunch of code examples from a bunch of different sites.
Pydev is giving me the following error message:
Undefined variable from import: Reddit
I can't find any source that shows how to resolve this issue. I'd appreciate some help.
EDIT:
Though the error message remains, I can still run the bot without issues. I don't understand why that would be, and would still like to know if I should try to fix something, but am glad it works.
Have you tried adding praw to the forced builtins? (to force it to be dynamically analyzed through a shell)
See: http://www.pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins for more details on the matter.
Related
Hi I am getting this error when I try to run a command:
Ignoring exception in command greet discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing
And when I try to manually pass the context with pass_context=True (I know this is outdated I think)It comes up with:
AttributeError: 'Context' object has no attribute 'send'
I have looked everywhere on various forums and I have found others with the same problem but the answers were always specific to that one user's issue and so were useless to me or were outdated, not using the rewrite. I would really appreciate it if someone could help.
Does anyone know why I am getting this and how I could fix it?
Here is what I think is the useful part of the code:
#client.command()
async def greet(ctx):
await ctx.send("Hello")
Here is the full code: https://pastebin.com/fQc4vE7F
Edit: I am on discord version 1.4.1 in case that might be useful
you should try re-installing discord.py, also make sure to put the following at the top:
from discord.ext import commands
import discord
The problem seemed to be my IDE. I ran my code in repl and it worked perfectly. Repl automatically installed all the modules. So the issue I think is likely to have been either my installations and imports running on pycharm conflicting with eachother or my pycharm version being outdated since I had not updated it in quite some time. PyCharm had been telling me that the version which I was on being outdated had some bugs with pip...
Anyway, in case anyone else has a similar issue I would recommend to try run your code in repl or some other IDE as the issue in this case was not my code but rather the setup. If you are encountering the same issue on a different IDE I would recommend repl as you do not have to install anything to your computer. Repl is entirely on the cloud and will only install and import what is necessary. And you should probably update the IDE which you already have. I hope I could help anyone else with a similar issue as I could find no solutions online, but I hope I could change this.
I have tried to run code shared on GitHub with my VScode via pylint.
But I'm getting this error message:
E1101:Module 'tensorflow.tools.api.generator.api.contrib' has no 'layers' member
What's the problem here? How can I solve it?
Here is the code: https://github.com/cj0012/AI-Practice-Tensorflow-Notes/blob/master/opt/opt4_8_forward.py
Pylint is wrong, the code runs fine. The problem is most likely related to the way TensorFlow generates its API.
The screenshot I took of the error message
Recently, Eclipse has been showing me this error message that basically says I'm referencing to a non-existent source: ${workspace_loc:project/project.py} every time I try to compile anything. I tried Debugging and it worked, but I was just wondering if there is a permanent fix to this problem, or if I am doing something incorrectly, since I am new to programming.
Thank you.
Do you have a project with name "project.py"?
Check your resources Location and give the path correctly to your project where the files are located
I've been reading through the internet for an answer and I cannot find anything! So I'm hoping you can help me with this problem. Finally, I've successfully installed it, but now I can not run ANY function and it's getting very annoying. I'll do something as simple as:
import pyautogui
pyautogui.onScreen(0, 2)
And boom! Error, I try every function on their "Cheat Sheet" and the same error!
AttributeError: CGDisplayPixelsWide
I've searched through the module, I've searched through the internet, and now I'm going to you! Please help me, I was really excited to use the functions this module offers.
PS - I'm on macOS Sierra
Trying to import a class into my Python code from another .py file I've written and included in the same sub-directory, however I'm receiving the error:
ModuleNotFoundError: No module named 'main.S_DES_Functions'; 'main' is not a package
Please find below images of the layout of my Python project.
I'm hoping this is just a really silly mistake I'm making, so if anyone can please advise what I'm doing wrong that'd be great :)
Thanks for the suggestions, I tried them however was still receiving the same error. But I managed to find a work around, similar to what is listed in this other Stack Overflow question - Unresolved reference issue in PyCharm
I basically made a new directory for my classes and set it as the directory as a "Source" for the project, which then allowed me to import it and use the classes without any issues.