SyntaxError for "from neuralintents import GenericAssistant" - discord

(this is my first post here sorry if I do things wrong)
I'm making a discord bot and I wanted to experiment with intents but when I try to run my code it says there's a syntax error, I've installed everything in the right place and there's no errors in the code itself only when I run it. Help would be greatly appreciated thanks.
error text:
Exception has occurred: SyntaxError
invalid syntax (pywrap_tensorflow_internal.py, line 114)
File "E:\Bot thing\main.py", line 11, in <module>
from neuralintents import GenericAssistant
All the code relevant to neuralintents is:
from neuralintents import GenericAssistant
chatbot = GenericAssistant("intents.json")
chatbot.train_model()
chatbot.save_model()

Related

selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression is invalid using By.XPATH through Selenium Python

I'm trying to develop an autologin für Instagram and I got the following problem.
Here is my code:
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
browser = webdriver.Firefox()
browser.implicitly_wait(5)
browser.get('https://www.instagram.com/')
sleep(2)
login_link = browser.find_element(By.XPATH,"//button[text()=´Allow essential and optional cookies`]")
Here is the Error Message:
Traceback (most recent call last): File "C:\Users\justu\PycharmProject\botinsta\main.py", line 18, in
login_link = browser.find_element(By.XPATH,"//button[text()=´Allow essential and optional cookies]") File "C:\Users\justu\PycharmProject\botinsta\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 857, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Users\justu\PycharmProject\botinsta\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 435, in execute self.error_handler.check_response(response) File "C:\Users\justu\PycharmProject\botinsta\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression "//button[text()=´Allow essential and optional cookies]" is invalid: SyntaxError: Document.evaluate: The expression
is not a legal expression Stacktrace:
WebDriverError#chrome://remote/content/shared/webdriver/Errors.jsm:188:5
InvalidSelectorError#chrome://remote/content/shared/webdriver/Errors.jsm:348:5
find_#chrome://remote/content/marionette/element.js:320:11
element.find/</findElements<#chrome://remote/content/marionette/element.js:274:24
evalFn#chrome://remote/content/marionette/sync.js:136:7
PollPromise/<#chrome://remote/content/marionette/sync.js:156:5
PollPromise#chrome://remote/content/marionette/sync.js:127:10
element.find/<#chrome://remote/content/marionette/element.js:272:24
element.find#chrome://remote/content/marionette/element.js:271:10
findElement#chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:245:25
receiveMessage#chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:101:31
Can anyone help ?
Try single quotes
'Allow essential and optional cookies'
instead of
´Allow essential and optional cookies`
P.S. Since you use browser.implicitly_wait(5) there is no need in time.sleep(2)
You need to take care of a couple of things.
If you are passing the xpath within double quotes i.e. "..." then you need to provide the value of the attribues within single quotes i.e. '...'
<button> element is a clickable element. So you need to identify when the element is interactable.
Solution
Incorporating the above mentioned points and removing the sleep(2), your effective lines of code will be:
browser.get('https://www.instagram.com/')
login_link = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Allow essential and optional cookies']")))
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

Im making a discord bot in discord.py and im getting a invalid syntax error and i dont know how to fix it

Here is my main embed code
embedVar = discord.Embed(title="Hello, and welcome to Alex's Bobux", description="Desc", color=#00ff00)
embedVar.add_field(name="Field1", value="hi", inline=False)
embedVar.add_field(name="Field2", value="hi2", inline=False)
await message.channel.send(embed=embedVar)
and this is the error im getting
File "main.py", line 21
embedVar.add_field(name="Field2", value="hi2", inline=False)
^
SyntaxError: invalid syntax
any help is most greatly appreciated, but for now thats my issue.
EDIT: ITS SOMETHING TO DO WITH PYTHON NOT TAKING MY HEX CODES, how do i fix it lol?
Your color was color=#....
The moment there is a #, it is considered to be a comment (as per your code) and that's why you have an invalid syntax error.
Solution:
Put the same within a String (color='#00ff00') or use 0x instead of # (color=0x00ff00)

My react app gives an error for some reason

Error:
src\images\navbar.js
Line 2:11: Parsing error: Unexpected token, expected "from" (2:11)
src\navbar.js
Line 2:11: Parsing error: Unexpected token, expected "from" (2:11)
the project on GitHub: https://github.com/PufflyMan/airbnb-exp-clone
It's pretty straightforward code but no matter what I tried, I couldn't fix it. Thanks for attention!
It just fixed itself. I didn't do anything

howtographql + React tutorial : Error: Cannot find module './generated/prisma.graphql'

I'm following the howtographql + React tutorial right now. I'm currently at the beginning of the tutorial when I have to define my queries, mutation and stuff in my schema.graphql. But according to the tutorial, I have to import prisma.graphql from the generatedfolder by writing the following line :
# import Link, Vote, LinkSubscriptionPayload, VoteSubscriptionPayload from "./generated/prisma.graphql"
I indeed generated the serverfolder which contains everything except this file that is supposed to be generated as well I guess.
Apparently, I should be able to run the server using yarn startbut when I'm doing so, I have this message :
Error: Cannot find module './generated/prisma.graphql'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
at resolveFileName (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/resolve-from/index.js:29:39)
at resolveFrom (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/resolve-from/index.js:43:9)
at module.exports (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/resolve-from/index.js:46:41)
at resolveModuleFilePath (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:150:24)
at /Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:187:30
at Array.forEach (<anonymous>)
at collectDefinitions (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:185:16)
at Object.importSchema (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:73:14)
at mergeTypeDefs (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-yoga/dist/index.js:412:37)
I don't understand what I'm doing wrong...
Do you guys have any idea ?

attributeeeror: opencv python on raspberry pi

When I try to run my code on python shell I'm getting following:
Attributeerror:'picamera' object has no attribute 'capature'
please help
import time
import picamera
with picamera.PiCamera() as camera:
camera.resolution = (1024, 768)
camera.start_preview()
# Camera warm-up time
time.sleep(2)
camera.capture('foo.jpg')
In the recipe from the picamera website, line 5 thru 9 are indented as they are part of the python 'with' statement.
Suggest you check the code is indented and correct. Your error message has a misspelling.

Resources