tweepy error while getting tweets - tweets

I'm collecting a large number of tweets via tweepy,
but after a while, it stops with the following message:
File "build/bdist.macosx-10.8-intel/egg/tweepy/binder.py", line 185, in _call
File "build/bdist.macosx-10.8-intel/egg/tweepy/binder.py", line 168, in execute
tweepy.error.TweepError: [{'message': 'Sorry, that page does not exist', 'code': 34}]
I'm only collecting the replies to already-existing tweets,
so I'm guessing it is the case where the replier misspelled the author of the original tweet..
Is there a workaround to ignore this and proceed?

I figured it out myself.
It was ridiculously simple..
You can just try/except and pass on the error.
try:
# do something
except tweepy.error.TweepError:
pass

Related

OSError: No space on device for weird reason

I am running some code that wasn't initially mine using GPT2-XL; it was initially implemented for GPT-Neo-1.3B and T5-Large. Running an experiment using GPT2-XL, I got the following error:
File "/data/username/directory", line 631, in to_tsr_gpt_entity_inference _bleu_score = BLEU.compute(predictions=definition, File "/data/username/miniconda3/lib/python3.9/site-packages/evaluate/module.py", line 433, in compute self._finalize() File "/data/username/miniconda3/lib/python3.9/site-packages/evaluate/module.py", line 372, in _finalize self.writer.finalize() File "/data/username/miniconda3/lib/python3.9/site-packages/datasets/arrow_writer.py", line 589, in finalize self.stream.close() File "/data/username/miniconda3/lib/python3.9/site-packages/fsspec/implementations/local.py", line 358, in close return self.f.close() OSError: [Errno 28] No space left on device
The issue here is that I'm not quite sure what is running out of space; I have checked df -h and df -I for example, and I tried setting the TMPDIR to be different with export TMPDIR=/new_directory, but that didn't work, so I can only assume something else is causing this to run out of space. It appears to have something to do with BLEU from the evaluate module of hugging_face, however, the same code (including the BLEU bit) works when running GPT-Neo/T5, so I'm not quite sure what the issue is.
I'd greatly appreciate any help in answering this question.

Anyone familiar with KeyError: 'v5' while using gekko

Anyone familiar with this error?
Traceback (most recent call last):
File "C:/Users/Geebug/Documents/ParameterEstimationGekko_v6.py", line 104, in <module>
m.solve()
File "C:\Users\Geebug\AppData\Local\Programs\Python\Python39\lib\site-packages\gekko\gekko.py", line 2227, in solve
self.load_JSON()
File "C:\Users\Geebug\AppData\Local\Programs\Python\Python39\lib\site-packages\gekko\gk_post_solve.py", line 70, in load_JSON
vp.__dict__[o] = data[vp.name][o]
KeyError: 'v5'
I am trying to solve a (parameter estimation) optimization problem in a loop using Gekko, such that the values of the parameter changes with every iteration and solves. The problem solve only the first two iterations and produces the above error message after the second iteration.
The KeyError is likely due a Gekko variable that is redefined as another Gekko variable so it no longer exists as an output. The error happens when the solution is returned to Python and loaded back into x.value after a solution is found.

'Error compiling Cython file error' from one day to another

I use a lot of special characters from Hun language, and there were no problems previously. Now they all give errors when running the whole script (F9). It still runs perfect when running locally (select + F5).
FĂșĂș='bar'
Traceback:
C:\Users\my name\.ipython\cython\_cython_magic_21a3824690cdb52a9fe6a3fa1c63ee73.pyx:1:1: Unrecognized character
Traceback (most recent call last):
File "<ipython-input-6-dcfab52d0ff4>", line 1, in <module>
runfile('E:/Anyagok/Programozas/Python/projekts/elo/mindennap/untitled0.pyx', wdir='E:/Anyagok/Programozas/Python/projekts/elo/mindennap')
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\spyder\utils\site\sitecustomize.py", line 703, in runfile
ipython_shell.run_cell_magic('cython', '', f.read())
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\IPython\core\interactiveshell.py", line 2131, in run_cell_magic
result = fn(magic_arg_s, cell)
File "<decorator-gen-130>", line 2, in cython
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\IPython\core\magic.py", line 187, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\Cython\Build\IpythonMagic.py", line 321, in cython
assert len(extensions) == 1
TypeError: object of type 'NoneType' has no len()
If I change to e.g.
Fuu='bar'
it works great. Why the sudden change of heart?
EDIT:
Have been messing around with FFMPEG and LIBAV yesterday, because wanted to download and convert Youtube videos to mp3. But I'm pretty sure I ran scripts with these characters succesfully after it.

WindowsError when calling sc.parallelize()

I want to use the sc.parallelize() function, but whenever I try to call it, I get the below error:
File "V:/PyCharmProjects/sample.py", line 9, in <module>
input_data = sc.parallelize(sc.textFile("C:\Users\Spider\Desktop\GM_coding\Sample Data.csv"))
File "V:\spark-2.2.0-bin-hadoop2.7\python\pyspark\context.py", line 497, in parallelize os.unlink(tempFile.name)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: u'C:\\Users\\Spider\\AppData\\Local\\Temp\\spark-fef6debd-ff91-4fb6-85dc-8c3a1da9690a\\pyspark-6ed523e7-358f-4e3c-ad83-a479fb8ecc52\\tmpxffhfi'
Not sure if it's relevant to your error (and cannot test it in Windows), but you are trying to parallelize something that is already an RDD (i.e. "parallelized"); from the docs:
textFile(name, minPartitions=None, use_unicode=True)
Read a text file from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI, and return it as an
RDD of Strings.
You don't need (and shouldn't use) sc.parallelize() here; the output of sc.textFile is already an RDD. You should simply go for
input_data = sc.textFile("C:\Users\Spider\Desktop\GM_coding\Sample Data.csv")
See also the example in the quick start guide.

Receiving the follow error [Invalid break (SyntaxError)] when opening helper_method file using require

I am new to ruby. I have created a helper method file for my watir scripts. When I try to run the script it hits this line:
require "C:/Sites/common/helper_methods"
and throws this error message:
C:/Sites/common/helper_methods.rb: C:/Sites/common/helper_methods.rb:1387: Invalid break (SyntaxError)
so I am not sure what the error means.
I have searched for an answer but can not find one that helps me figure out the message.
Any help would be appreciated.
Joe
Hi Paul,
Here is the method before 1387
#Write Subject Lines to file
def add_subject_line_to_file(s)
project_path = Dir.pwd
fileNamePath = File.join(project_path,'data_files','multi_add_discussion_files','multi_add_discussion_headers.txt')
#Writing to new file
open(fileNamePath,'a+'){ |f|
f << "#{s}\n"
}
end
which might be the problem
the method after 1387
#The following method will validate text at on the page not in a specific location
def text_validation(rt)
#Validate comment displays
if #browser.text.include? rt
#Response
response = "PASS!!! The following user comment was found [ #{rt} ]."
write_to_file(response)
else
#Response
response = "FAIL!!! The following user comment was NOT found [ #{rt} ]."
write_to_file(response)
end #End of Validate comment displays
end
The line:
C:/Sites/common/helper_methods.rb:
C:/Sites/common/helper_methods.rb:1387:
Invalid break (SyntaxError)
means there's an error parsing (SyntaxError) on line 1387 of helper_methods.rb ( ...helper_methods.rb:1387).
It's possible that the error occurs much earlier but the interpreter is only able to notice it at line 1387. Posting the lines around line 1387 may help diagnose further.
1378 is a lot of lines to have in one file. You may want to think about breaking those methods up into related hunks and include only the portions you need. Doing this would also help find the error if you could require 5 or 6 you know the error is in the one file you can't require. You could also try commenting out methods in the helper_methods until you find the one that triggers the problem.

Resources