Octave can't read file using GraphicsMagick - octave

I'm trying to load an image in Octave 4.2.1 with GraphicsMagick 1.3.27 (via brew) on OS X. Here's the error:
>> img = imread('./myimg.jpg')
error: Magick++ exception: octave-cli-4.2: No decode delegate for this
image format (<path to myimg.jpg>) reported by magick/constitute.c:1535 (ReadImage)
error: called from
__imread__ at line 80 column 10
imageIO at line 117 column 26
imread at line 106 column 30
GraphicsMagick looks to be configured correctly:
gm -version
GraphicsMagick 1.3.27 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2017 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP yes
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG no
JPEG-2000 no
JPEG yes
Little CMS no
Loadable Modules yes
OpenMP no
PNG yes
TIFF yes
TRIO no
UMEM no
WebP no
WMF no
X11 no
XML no
ZLIB yes
Host type: x86_64-apple-darwin16.7.0
Configured using the command:
./configure '--prefix=/usr/local/Cellar/graphicsmagick/1.3.27' '--
disable-dependency-tracking' '--enable-shared' '--disable-static' '--with-modules' '--without-lzma' '--disable-openmp' '--with-quantum-depth=16' '--disable-installed' '--without-gslib' '--with-gs-font-dir=/usr/local/share/ghostscript/fonts' '--without-x' '--without-lcms2' 'CC=clang' 'CXX=clang++'
Final Build Parameters:
CC = clang
CFLAGS = -g -O2 -Wall -D_THREAD_SAFE
CPPFLAGS = -I/usr/local/opt/freetype/include/freetype2
CXX = clang++
CXXFLAGS = -D_THREAD_SAFE
LDFLAGS = -L/usr/local/opt/freetype/lib
LIBS = -lfreetype -lbz2 -lz -lltdl -lm -lpthread
Trying to load a png file results in the same error. Using gm directly from the command line works fine.

Your octave and gm installation may be linked against different GraphicsMagick libraries so the output of gm -version might not be accurate. You probably should be checking this from inside Octave itself, like so:
octave:1> imformats
Extension | isa | Info | Read | Write | Alpha | Description
----------+-----+------+------+-------+-------+------------
bmp | yes | yes | yes | yes | yes | Microsoft Windows bitmap image
cur | yes | yes | yes | no | yes | Microsoft Cursor Icon
gif | yes | yes | yes | yes | yes | CompuServe graphics interchange format
ico | yes | yes | yes | no | yes | Microsoft Icon
jbg | yes | yes | yes | yes | yes | Joint Bi-level Image experts Group interchange format
jbig | yes | yes | yes | yes | yes | Joint Bi-level Image experts Group interchange format
jpg, jpeg | yes | yes | yes | yes | yes | Joint Photographic Experts Group JFIF format
pbm | yes | yes | yes | yes | yes | Portable bitmap format (black/white)
pcx | yes | yes | yes | yes | yes | ZSoft IBM PC Paintbrush
pgm | yes | yes | yes | yes | yes | Portable graymap format (gray scale)
png | yes | yes | yes | yes | yes | Portable Network Graphics
pnm | yes | yes | yes | yes | yes | Portable anymap
ppm | yes | yes | yes | yes | yes | Portable pixmap format (color)
ras | yes | yes | yes | yes | yes | SUN Rasterfile
tga, tpic | yes | yes | yes | yes | yes | Truevision Targa image
tif, tiff | yes | yes | yes | yes | yes | Tagged Image File Format
xbm | yes | yes | yes | yes | yes | X Windows system bitmap (black/white)
xpm | yes | yes | yes | yes | yes | X Windows system pixmap (color)
xwd | yes | yes | yes | yes | yes | X Windows system window dump (color)
You can also check what library is Octave actually using with ldd (since your are using Mac, you might not have ldd but google tells me otool -L is the Mac solution). In my case I know they are the same:
$ ldd /usr/local/lib/octave/5.0.0/liboctinterp.so | grep Magick
libGraphicsMagick++-Q16.so.12 => /lib/libGraphicsMagick++-Q16.so.12 (0x00007f858a896000)
libGraphicsMagick-Q16.so.3 => /lib/libGraphicsMagick-Q16.so.3 (0x00007f858a52e000)
$ ldd /usr/bin/gm | grep Magick
libGraphicsMagick-Q16.so.3 => /lib/libGraphicsMagick-Q16.so.3 (0x00007f5041f66000)
And once you know the actual library that Octave is using for GraphicsMagick, you can check if that one is linked against libjpeg:
$ ldd /lib/libGraphicsMagick++-Q16.so.12 | grep jpeg
libjpeg.so.62 => /lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f63e910c000)
You may also be able to get some hints from octave config:
octave:1> __octave_config_info__.build_environment.MAGICK_CPPFLAGS
ans = -I/usr/include/GraphicsMagick
octave:2> __octave_config_info__.build_environment.MAGICK_LDFLAGS
ans =
octave:3> __octave_config_info__.build_environment.MAGICK_LIBS
ans = -lGraphicsMagick++ -lGraphicsMagick

Related

Etcd: how to check that each node can see each other

I have 3 etcd nodes on VMs (not k8s).
There was such problem that nodes are alive but can't see each other, error "connection timeout" during health check. But every single node has "alive" status and zabbix with "etcd by http" template doesn't generate any alerts.
Is there any way to check nodes visibility and to monitor it using zabbix?
Depending upon the version you run, here's an example to do this with 3.5.2
Command
ETCDCTL_API=3 ./bin/etcdctl endpoint status --cluster -w table --endpoints="member1.etcd:2384,member2.etcd:2384,member3.etcd:2384"
Output:
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+--------------------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| http://member1.etcd:2384 | 17ef476d9d7fec5f | 3.5.2 | 1.5 MB | false | false | 7 | 20033 | 20033 | |
| http://member2.etcd:2384 | 31e0ca30ec3c9d94 | 3.5.2 | 1.5 MB | false | false | 7 | 20033 | 20033 | |
| http://member3.etcd:2384 | 721948abbb0522bd | 3.5.2 | 1.5 MB | false | false | 7 | 20033 | 20033 | |
+--------------------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+

Uploading Python Pandas dataframe to MySQL - InternalError: 1366, "Incorrect String Value"

I am trying to write a Pandas dataframe into MySQL database, and have used the following code:
engine = sqlalchemy.create_engine("mysql+pymysql://root:password#localhost/skills?charset=utf8mb4")
connection = engine.connect
dataframe.head().to_sql('indeed_resumes', engine, flavor='mysql', if_exists='replace',index=True)
However, I get the following error:
InternalError: (1366, "Incorrect string value: '\\xE1\\xBB\\x99i\\x0AO...' for column 'work' at row 5")
The datatype of the MySQL table is as follows:
mysql> desc indeed_resumes;
+-----------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------+------+-----+---------+-------+
| index | bigint(20) | YES | MUL | NULL | |
| certs | text | YES | | NULL | |
| contact | text | YES | | NULL | |
| education | text | YES | | NULL | |
| headline | text | YES | | NULL | |
| info | text | YES | | NULL | |
| skills | text | YES | | NULL | |
| summary | text | YES | | NULL | |
| updated | text | YES | | NULL | |
| work | text | YES | | NULL | |
+-----------+------------+------+-----+---------+-------+
10 rows in set (0.00 sec)
My data consists of very long strings (sometimes around 3000 characters), so this could be causing the error. Any suggestions?
I seem to have resolved this issue. It looks like I also needed to change the database encoding using the following commands.
ALTER DATABASE skills CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE indeed_resumes CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
From https://mathiasbynens.be/notes/mysql-utf8mb4:
"Turns out MySQL’s utf8 charset only partially implements proper UTF-8 encoding. It can only store UTF-8-encoded symbols that consist of one to three bytes; encoded symbols that take up four bytes aren’t supported.
Luckily, MySQL 5.5.3 (released in early 2010) introduced a new encoding called utf8mb4 which maps to proper UTF-8 and thus fully supports Unicode, including astral symbols."

Table type CSV dont created

I created a table type CSV but in PHPMyAdmin was created table with type MRG_MYISAM.
I read https://dev.mysql.com/doc/refman/5.1/en/csv-storage-engine.html
To enable the CSV storage engine if you build MySQL from source,
invoke configure with the --with-csv-storage-engine option.
Is it possible other methods to include this type ? Maybe my.ini ....
In order to know what storage engines are available you can run the following query:
show engines
The output will look like this:
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| MyISAM | YES | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
As the documentation you've read explains, it's possible to decide on compilation time whether the MySQL binaries will include support for the CSV engine. If they don't, it's just not possible to use it. You cannot enable something that doesn't exist ;-)

Mysql update on linux box hangs

I have a MYSQL database on my Windows machine and another similar set up on Linux server.
While I had no issues in executing a very basic update/delete/drop query on Windows set up, my query hangs when run on Linux server.
MYSQL version on Windows machine is 5.1.42 while for Linux is 5.6.5-m8
Also, the hanging of update is not limited to a single table. There are 4-5 cross referencing tables in my datatabase for which this update/delete/drop is hanging.
Update/delete/drop is working for other un-related tables though.
On Linux, First, I simply source a dump(with no inserts) generated from my Windows machine. Second, I run an insert statement (insert into flat (FLATID, BLOCKNO, FLATNO) Values (1, 'B1','F1');).
Third, I run update on the table(UPDATE FLAT SET FLATNO='F2';) and it hangs.
flat table description is below:
+----------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+----------------+
| FLATID | bigint(20) | NO | PRI | NULL | auto_increment |
||BLOCKNO | varchar(20) | NO | | NULL | |
| FLATNO | varchar(10) | NO | | NULL | |
||col_COLID | int(11) | YES | MUL | NULL | |
| famID_FAMID | bigint(20) | YES | MUL | NULL | |
| | allotID_ALLOTID | bigint(20) | YES | MUL | NULL | |
|+----------------------+--------------+------+-----+---------+----------------+
After having tried almost everything including playing around with INNODB variables, i eventually tried removing reference allotID_ALLOTID from flat table.
The ALLOTMENT table had reference to FAMILY table to which FLAT table had reference to as well.
Removing allotID_ALLOTID from both flat, family tables worked.

change default mysql storage engine on Ubuntu

I've installed mysql 5.1.49 on Ubuntu. I've added the following line to the end of /etc/mysql/my.cnf
default-storage-engine=innodb
I've restarted the mysqld process, then run
mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
As you can see MyISAM is still the default, what am I missing? I've also run
sudo find / -name 'my.cnf'
to verify that there is no other my.cnf file present on the system
It's probably in the wrong section of the my.cnf file.
You need to set that variable in the [mysqld] section. If you put it at the end of the config file, it's probably in a different section, since [mysqld] is typically the first section, not the last.
Verify that you have put default-storage-engine=innodb in the appropriate [group], usually [mysqld].