Str_length function UFT-8 byte sequence detected - tidyverse

I imported a data set and the function str_length() is not working. This is the error I get:
str_length(hw4$CompleteReview)
Error in stri_length(string) :
invalid UTF-8 byte sequence detected; try calling stri_enc_toutf8()
I tried uninstalling and reloading tidyverse. I uninstalled and reinstalled stringr and stringi, and I tried the function stri_length. None of them work, even if I call the package before the funtion.

Related

Kmodes function Error in x[[jj]][iseq] <- vjj : replacement has length zero

I got this error when using a big data set, I cleaned the data and used Data<-na.omit(Data) to delete all rows with nulls, it worked and in RStudio I don't get any errors.
When I run the script in SQL as an external script I get the same error as before
Error in x[[jj]][iseq] <- vjj : replacement has length zero
even though I'm using the same Rscript and dataset is the same.
Has anyone had the same issue and how did you solve it.
thanks

Errors in October CMS installation via cPanel

I just installed October CMS on my hosting platform via cPanel's Softaculous utility. I do not believe installation method has anything to do with my errors but mentioning it just in case I am wrong.
October CMS Version: 1.0.458
Sever PHP Version: 7.3.3
After installing in the designated directory it is showing "HTTP 500" generic error so I checked the error log. Following error was being shown
"[28-Sep-2019 11:09:04 Etc/GMT] PHP Parse error: syntax error, unexpected '[', expecting ')' in /home/XYZ/public_html/XYZ/vendor/october/rain/src/Support/helpers.php on line 149"
There is absolutely no online resource which describes occurance of such an error and possible solution. So I opened the helper.php to look at line 149. The code on this line was,
$query = str_replace(['%', '?'], ['%%', '%s'], $query);
Now there is nothing seemingly wrong with this line but I thought may be the "str_replace" function is not able to understand the array arguments. So I removed the array arguments and wrote it two times like
$query = str_replace('%', '%%', $query);
$query = str_replace('?', '%s', $query);
Now the error on this line disappears but a new error appears on another line as follows
PHP Parse error: syntax error, unexpected '[' in /home/XYZ/public_html/XYZ/vendor/october/rain/src/Support/helpers.php on line 238
The code on this line is
function trans($id = null, $parameters = [], $domain = 'messages', $locale = null)
Now here I am not sure if removing brackets would make everything alright. Why should such strange errors appears? Can someone help?
Are you 100% sure the PHP version you're using is 7.3.3?
The short array syntax of using [ ... ] instead of array( ... ) was introduced in PHP 5.4 and the errors you are getting are the errors that will happen if you are using an older version of PHP. I'm not sure how cPanel Softaculous works, but perhaps somehow it set you up to use a different version of PHP then you expect.
I would try running phpinfo() to double check your PHP setup.

redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first

I've recently started to use Redis and RQ to run background processes. I built a Dash app which works fine on Heroku and used to work locally as well. Recently, I tried to test the same app locally again and I keep getting the following error - although I'm using exactly the same code hosted on Heroku:
redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.
In my requirements.txt and virtual env on Ubuntu 18.04 I have redis v.3.0.1, rq 0.13.0
When I run redis-server on my terminal I see that Redis 4.0.9 is used (that's also confusing to me).
I tried to google for two days looking for a solution with no avail.
Has anyone an idea of what might have happened and how to solve this error?
Here is the full relevant traceback:
File "/home/tom/dashenv/pb101_models/pages/cumulative_culture.py", line 1026, in stop_or_start_update
job = q.fetch_job(job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 142, in fetch_job
self.remove(job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 186, in remove
return self.connection.lrem(self.key, 1, job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 1580, in lrem
return self.execute_command('LREM', name, count, value)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 754, in execute_command
connection.send_command(*args)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 619, in send_command
self.send_packed_command(self.pack_command(*args))
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 659, in pack_command
for arg in imap(self.encoder.encode, args):
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 124, in encode
"byte, string or number first." % typename)
redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.
Thanks in advance for any suggestion/hint.
All best,
Tom
Check this link: redis 3.0
It says that the redis-py no longer accepts NoneType
Try json.dumps(None), that worked for me

VBA Error: The buffer supplied to a function was too small

I'm running a function and getting this error:
Error # -2146893023 was generated by MSXML6.DLL
Error line: 0
The buffer supplied to a function was too small.
Any clue why this is happening?

PyAudio warnings poluting output

I have this program that listens to the microphone and tries to recognize what was said:
#!/usr/bin/env python3
import speech_recognition
recognizer = speech_recognition.Recognizer()
class Recognition:
def __init__(self):
self.recognizer = speech_recognition.Recognizer()
def listen(self):
with speech_recognition.Microphone() as source:
self.recognizer.adjust_for_ambient_noise(source)
self.audio = self.recognizer.listen(source)
def recognize_sphinx(self):
decoder = self.recognizer.recognize_sphinx(self.audio, show_all=True)
for best, i in zip(decoder.nbest(), range(10)):
return best.hypstr
r = Recognition()
r.listen()
print(r.recognize_sphinx())
Although the code works, it does display the following warnings along with the output:
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
potato
The problem is I want a script to execute the code above and read its output (potato), but the returned result is mixed with all those errors. I tried the solution I saw here, but it only suppress the alsa warnings. Probably messing with alsa/pulseaudio configs will solve this problem, but I don't want to do that on every machine that runs the code.
I also tried redirecting stdin/stderr to null, but didn't suppress anything.
I have a workaround in mind that is, when the script runs this program, to get only the last line, but I want that only as a last resource.
The warning/status messages go to the standard error output (stderr), while the output of your print() call goes to the standard output (stdout).
It should be trivial to separate the two.
If you want to actually suppress the warning/status messages, you can have a look at my answer to the SO-question you were mentioning, or the more verbose answer I've linked to from there.