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.
Related
(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()
when I Integrating Jmeter With Selenium and run it the error is showing.
anyone please help me .
Thread Name:Thread Group 1-1
Sample Start:2022-03-06 14:01:19 IST
Load time:0
Connect Time:0
Latency:0
Size in bytes:1006
Sent bytes:0
Headers size in bytes:0
Body size in bytes:1006
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:500
Response message:In file: inline evaluation of: WDS.sampleResult.sampleStart() WDS.browser.get('https://www.facebook.com') WDS.s . . . '' Encountered "WDS" at line 2, column 1. in inline evaluation of: WDS.sampleResult.sampleStart() WDS.browser.get('https://www.facebook.com') WDS.s . . . '' at line number 2
SampleResult fields:
ContentType: text/plain
DataEncoding: UTF-8
Make sure to install Selenium/WebDriver Support package using JMeter Plugins Manager, this way you will get the WebDriver Sampler
Add the configuration element for your browser and provide binary and/or driver details there
Add WebDriver Sampler to your test plan and put your code there
Your error means that you're trying to run your code using Beanshell interpreter and you're using incorrect syntax, i.e.
Strings should be surrounded by double quotation marks
There should be semicolons at the end of every statement
Something like:
WDS.sampleResult.sampleStart();
WDS.browser.get("https://www.facebook.com");
Otherwise check the page where you did get the code and pay attention to the language of the WebDriver Sampler, the default is javascript, the recommended is groovy
I've decided to experiment with apache flink a bit. I decided to use scala console (or more precisely http://ammonite.io/) to read some stuff from csv file and print it locally... just to debug end experiments.
import $ivy.`org.apache.flink:flink-csv:1.10.0`
import $ivy.`org.apache.flink::flink-scala:1.10.0`
import org.apache.flink.api.scala._
import org.apache.flink.api.scala.extensions._
val env = ExecutionEnvironment.createLocalEnvironment()
val lines = env.readCsvFile[(String, String, String)]("/home/slovic/Dokumenty/test.csv")
lines.collect()
//java.lang.NullPointerException: Cannot find compatible factory for specified execution.target (=local)
//org.apache.flink.util.Preconditions.checkNotNull(Preconditions.java:104)
//org.apache.flink.api.java.ExecutionEnvironment.executeAsync(ExecutionEnvironment.java:937)
//org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:860)
//org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:844)
//org.apache.flink.api.scala.ExecutionEnvironment.execute(ExecutionEnvironment.scala:495)
//org.apache.flink.api.scala.DataSet.collect(DataSet.scala:739)
//ammonite.$sess.cmd24$.<init>(cmd24.sc:1)
//ammonite.$sess.cmd24$.<clinit>(cmd24.sc)
What I need to do to run this code locally? (tested with scala 2.11 & 2.12)
EDIT: SOLLUTION BY Piyush_Rana
We need additional import:
import $ivy.`org.apache.flink::flink-streaming-scala:1.10.0` //Piyush_Rana's advice. !!!FIX!!!
I also got the same error and figured out that was missing one dependency -
val flinkVersion = "1.10.0"
"org.apache.flink" %% "flink-streaming-scala" % flinkVersion,
or in ammonite repl:
import $ivy.`org.apache.flink::flink-streaming-scala:1.10.0`
You didnt execute the flink program .
Try to add execute command at the end.
env.execute("unique name")
I am using Netbeans and updated to use the latest codenameone plugin. I am trying to follow the walkthrough tutorial at http://www.codenameone.com/blog/gui-builder-walkthru.html, but I keep on getting a StringIndexOutOfBoundsException when attempting to generate a new Form using the NewGuiBuilderWizardIterator. The following is the stacktrace that I'm seeing. Any and all help would be greatly appreciated!
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: Relative path com\mycompany\myapp\MyApp.java
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: Gui file C:\Users\joshua\Documents\NetBeansProjects\TestGui1\res\guibuilder\com\mycompany\myapp\MyApp.gui
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: Props C:\Users\joshua\Documents\NetBeansProjects\TestGui1\codenameone_settings.properties
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: The GUI file doesn't exist!
WARNING [org.openide.filesystems.Ordering]: Found same position 100 for both Loaders/application/res/Actions/org-openide-actions-OpenAction.shadow and Loaders/application/res/Actions/sep-1.instance
WARNING [org.netbeans.modules.java.JavaTemplateAttributesProvider]: No classpath was found for folder: C:\Users\joshua\Documents\NetBeansProjects\TestGui1#b78894d2:1aed2d64
WARNING [org.openide.WizardDescriptor]
java.lang.StringIndexOutOfBoundsException: String index out of range: -4
at java.lang.String.substring(String.java:1919)
at com.codename1.NewGuiBuilderWizardIterator.instantiate(NewGuiBuilderWizardIterator.java:95)
at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1046)
at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:605)
at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:439)
at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:248)
at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:160)
at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1629)
at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1570)
at org.openide.WizardDescriptor.access$2300(WizardDescriptor.java:92)
[catch] at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2257)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
You need to select a package when you do this and not the top level project since the code won't recognize that situation and won't know where to place the GUI file.
Notice that since an XML GUI file is created in the background, refactoring after the fact won't work well so this isn't something we should generally fix.
I am using the following code, as recommended here: Is there a way to use PhantomJS in Python?.
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.set_window_size(1024, 768) # optional
driver.get('https://google.com/')
driver.save_screenshot('screen.png') # save a screenshot to disk
sbtn = driver.find_element_by_css_selector('button.gbqfba')
sbtn.click()
When I try to run it I get the following error:
WebDriverException - "Unable to start phantomjs with ghostdriver."
Apparently, this error can be solved by replacing the 3rd line with:
driver = webdriver.PhantomJS(executable_path='/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs')
I'm using Windows7, and the path for me appears to be: "C:\Users\myname\AppData\Roaming\npm\node_modules\phantomjs\bin\phantomjs". I have tried using this and variations of it as the executable_path, but I still get the same error. I have also tried adding the folder location to the path. Nothing has worked. I suspect that I am missing something pretty obvious.
Aha!
It was a slightly different location. The line I was looking for was:
driver = webdriver.PhantomJS(executable_path=r'C:\Users\myname\AppData\Roaming\npm\node_modules\phantomjs\lib\phantom\phantomjs')