Tess4J on Ubuntu Linux, UnsatisfiedLinkError - linux

I am getting a getting an UnsatisfiedLinkError using Tess4j in Tomcat+Ubuntu(Linux)
java.lang.UnsatisfiedLinkError: Error looking up function 'TessBaseAPICreate': /usr/lib/libtesseract.so.3.0.2: undefined symbol: TessBaseAPICreate
at com.sun.jna.Function.<init>(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
Library is installed via apt-get install tesseract-ocr, Tess4j version is 2.0.0, everything seems to work on a MacOS/OracleJDK1.7(64bits), but not in Ubuntu/Linux/OracleJDK1.7(64bits)
Some stackoverflow-search gives clues about wrong versions or library not present, but the library is right there...
ls -al /usr/lib/libtesseract.so.3.0.2
-rw-r--r-- 1 root root 4219544 Feb 25 2012 /usr/lib/libtesseract.so.3.0.2
Someone with a solution or a hint?

Tess4J 2.0 is compatible with Tesseract 3.03RC. Since yours is 3.02, you'd need Tess4J 1.x version.

this may be the version of tesseract is not compatible to ubuntu version
as to me my program runs in win10 and ubuntu 16 has no error ,but when in ubuntu 12.04 this error occurs
maybe I install tesseract by the command
sudo apt-get install tesseract-ocr
but indeed in ubuntu 12 after i install by the flow
sudo apt-get install libpng-dev libjpeg-dev libtiff-dev zlib1g-dev
sudo apt-get install gcc g++
sudo apt-get install autoconf automake libtool checkinstall
Install Leptonica from source. The latest version as of writing is 1.69.
wget http://www.leptonica.org/source/leptonica-1.69.tar.gz (if you can't,download leptonica-1.69.tar.gz from the internet)
tar -zxvf leptonica-1.69.tar.gz
cd leptonica-1.69
./configure
make
sudo checkinstall
sudo ldconfig
Then install Tesseract OCR from source.
wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
(maybe you can download tesseract-ocr-3.02.02.tar.gz from the internet and then upload to the server )
tar -zxvf tesseract-ocr-3.02.02.tar.gz
cd tesseract-ocr
./autogen.sh
./configure
make (this may take a while)
sudo make install
sudo ldconfig
after this i solve this problem

Related

How to reinstall the latest cmake version?

I would like to install cmake the latest version, on Linux environment. I have cmake version 3.5 installed and is not supported by some applications. I tried to upgrade it by uninstalling the current version. But when I reinstall with sudo apt-get install cmake, I get the same version 3.5 re-installed. How do I install the latest version with sudo apt-get install ....?
As far as I know the best way to get the latest CMake version installed on any Linux is not by apt but using pip.
Remove the apt cmake and install the latest version from pip which can easily keep up-to-date.
apt remove cmake -y
pip install cmake --upgrade
Edit: As GNUton has pointed out, the following only works on Ubuntu 16.04 and 18.04(Checked on June 2019).
Now CMake developer team in Kitware Inc provides APT repositiory. It allows you to install latest CMake via apt-get.
If you are using a minimal Ubuntu image or a Docker image, you may need to install the following packages:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg \
software-properties-common wget
Obtain a copy of our signing key:
wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc |
sudo apt-key add -
Add the repository to your sources list and update.
For Ubuntu Bionic Beaver (18.04):
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update
For Ubuntu Xenial Xerus (16.04):
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt-get update
... Optional steps. See details in reference.
... Optional steps. See details in reference.
Now call
sudo apt-get install cmake
Reference: Kitware APT Repository.
You can try the following steps that have worked for me on Ubuntu 18.04.3 LTS as OS of the NVIDIA jetson Nano to get the last version of cmake "cmake-3.14.0" from https://cmake.org/download/.
Delete the installed version in your system
sudo apt purge cmake
Download cmake3.13.4 source
wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz
Extract files
tar zxvf cmake-3.13.4.tar.gz
Execute the following commands in this order to build it
cd cmake-3.13.4
sudo ./bootstrap
sudo make
sudo make install
Verify the version is installed correctly
cmake --version
Following the comments made on how to Install the latest CMake version and to post the answer for this question:
Ans:
This depends with Ubuntu OS version currently installed on your PC or Mac. If you have the following Ubuntu OS version then you have this CMake installed or that you could install and reinstall with "sudo apt-get install cmake". Even if you uninstall your version and try to reinstall later version.
Ubuntu 16.04 ships with cmake-3.5.1
Ubuntu 17.10 ships with cmake-3.9.1
Ubuntu 18.04 ships with cmake-3.10.2
Ubuntu 20.04 ships with cmake-3.16.3
Ubuntu 21.04 ships with cmake-3.18.4
Now if you have Ubuntu 16.04 installed and you want cmake-3.10, there is OS problem since you can only install and reinstalled cmake-3.5.1. To get cmake-3.10 or any other version, you have to download and install the package from https://packages.ubuntu.com/. Once you find the latest version of cmake .targz files, you have to build it yourself from the command line.
For CentOS/RHEL you can help these following steps:
yum -y install python-pip
pip install cmake --upgrade
If you are using Google Colab like me and wanted a higher version of cmake in it. Then do the following,
!pip uninstall cmake
!pip install cmake
This will install cmake 3.22 instead of the default version 3.12
pip install cmake --upgrade
if the following occurs after cmake .. :
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/.../.../...
CMake Error: Error executing cmake::LoadCache(). Aborting.
then try
hash -r
the following worked for me:
sudo apt remove cmake
pip install cmake --upgrade
then, I exited the terminal and again entered to check the version with cmake --version command
3.20.5 in ubuntu 16.04
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DE19EB17684BA42D
sudo apt install cmake cmake-qt-gui cmake-curses-gui
yum remove cmake
wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz
tar zxvf cmake-3.13.4.tar.gz
cd cmake-3.13.4
sudo ./bootstrap --prefix=/usr/local
sudo make
sudo make install
vi ~/.bash_profile
...
# PATH=$PATH:$HOME/bin
PATH=/usr/local/bin:$PATH:$HOME/bin
export PATH
source ~/.bash_profile
cmake --version
vi ~/.bash_profile
centos7 it help me
In case someone still finds it hard to remove cmake from their machine.
This command works for me (requires sudo permissions):
$ sudo find / -name "cmake" | xargs -I % sudo rm -rf "%"

flask-mysqldb support for Python 3.6? [duplicate]

I am trying to get a Python script to run on the linux server I'm connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to install mySQLdb via setuptools like so:,
python setup.py install
I get the following error report related to the mysql_config command.
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Has anyone else encountered this error and if so how did you resolve it/what can I do to successfully install mysqldb?
mySQLdb is a python interface for mysql, but it is not mysql itself. And apparently mySQLdb needs the command 'mysql_config', so you need to install that first.
Can you confirm that you did or did not install mysql itself, by running "mysql" from the shell? That should give you a response other than "mysql: command not found".
Which linux distribution are you using? Mysql is pre-packaged for most linux distributions. For example, for debian / ubuntu, installing mysql is as easy as
sudo apt-get install mysql-server
mysql-config is in a different package, which can be installed from (again, assuming debian / ubuntu):
sudo apt-get install libmysqlclient-dev
if you are using mariadb, the drop in replacement for mysql, then run
sudo apt-get install libmariadbclient-dev
Reference:
https://github.com/JudgeGirl/Judge-sender/issues/4#issuecomment-186542797
I was installing python-mysql on Ubuntu 12.04 using
pip install mysql-python
First I had the same problem:
Not Found "mysql_config"
This worked for me
$ sudo apt-get install libmysqlclient-dev
Then I had this problem:
...
_mysql.c:29:20: error fatal: Python.h: No existe el archivo o el directorio
compilación terminada.
error: command 'gcc' failed with exit status 1
Then I tried with
apt-get install python-dev
(If you're using python3, install python3-dev instead.)
And then I was happy :)
pip install mysql-python
Installing collected packages: mysql-python
Running setup.py install for mysql-python
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g
In file included from _mysql.c:44:0:
/usr/include/mysql/my_config.h:422:0: aviso: se redefinió "HAVE_WCSCOLL" [activado por defecto]
/usr/include/python2.7/pyconfig.h:890:0: nota: esta es la ubicación de la definición previa
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
Successfully installed mysql-python
Cleaning up...
(Specific to Mac OS X)
I have tried a lot of things, but these set of commands finally worked for me.
Install mysql
brew install mysql
brew unlink mysql
brew install mysql-connector-c
Add the mysql bin folder to PATH
export PATH=/usr/local/Cellar/mysql/8.0.11/bin:$PATH
mkdir /usr/local/Cellar/lib/
Create a symlink
sudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.21.dylib /usr/local/Cellar/lib/libmysqlclient.21.dylib
brew reinstall openssl (source)
Finally, install mysql-client
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ pip install mysqlclient
Update:
In case this doesn't work, #vinyll suggests to run brew link mysql before step 8.
On Red Hat I had to do
sudo yum install mysql-devel gcc gcc-devel python-devel
sudo easy_install mysql-python
Then it worked.
On python 3.5.2 + any future version
sudo apt-get install libmysqlclient-dev python-dev
The below worked for me on Ubuntu 12.04 LTS:
apt-get install libmysqlclient-dev python-dev
All though it worked, i still went ahead to do the below:
export PATH=$PATH:/usr/local/mysql/bin/
I got the same error while trying to install mysql-python.
This is how I fixed it.
sudo PATH=/usr/local/mysql/bin/:$PATH pip install mysql-python
The problem was that the installer could not find the mysql_config in the default path. Now it can ..and it worked..
15 warnings generated.
clang -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.8-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.8-intel-2.7/_mysql.so -arch x86_64
Successfully installed mysql-python
Cleaning up...
Hope this helps.
Thanks.
I fixed this problem with the following steps:
sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
sudo python setup.py install
The commands (mysql too) mPATH might be missing.
export PATH=$PATH:/usr/local/mysql/bin/
Step1:-Install Python3 & Python3-dev Both
sudo apt-get install python3 python3-dev
Step2:- Install Python & Mysql Connector
sudo apt-get install libmysqlclient-dev
step3:- Install python mysql client
sudo apt-get install mysqlclient
This will Solve your Problem
The package libmysqlclient-dev is deprecated, so use the below command to fix it.
Package libmysqlclient-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
sudo apt-get install default-libmysqlclient-dev
I think the most convenient way to solve this problem in 2020 is using another python package. We don't need install any other binary software.
Try this
pip install mysql-connector-python
and then
import mysql.connector
mydb = mysql.connector.connect(
host="",
user="",
passwd="",
database=""
)
cursor = mydb.cursor( buffered=True)
cursor.execute('show tables;')
cursor.execute('insert into test values (null, "a",10)')
mydb.commit()
mydb.disconnect()
If you're on macOS and already installed mysql#5.7 via brew install:
brew install mysql-connector-c
brew unlink mysql#5.7
brew link --overwrite --dry-run mysql#5.7 first, to see what symlinks are getting overwritten
brew link --overwrite --force mysql#5.7 to actually overwrite mysql-related symlinks with mysql#5.7
pip install mysqlclient
I fixed it by installing libmysqlclient:
sudo apt-get install libmysqlclient16-dev
In centos 7 this works for me :
yum install mariadb-devel
pip install mysqlclient
The MySQL-python package is using the mysql_config command to learn about the mysql configuration on your host. Your host does not have the mysql_config command.
The MySQL development libraries package (MySQL-devel-xxx) from dev.mysql.com provides this command and the libraries needed by the MySQL-python package. The MySQL-devel packages are found in the download - community server area. The MySQL development library package names start with MySQL-devel and vary based MySQL version and linux platform (e.g. MySQL-devel-5.5.24-1.linux2.6.x86_64.rpm.)
Note that you do not need to install mysql server.
For Alpine Linux:
$ apk add mariadb-dev mariadb-client mariadb-libs
MariaDB is a drop-in replacement for MySQL and became the new standard as of Alpine 3.2. See https://bugs.alpinelinux.org/issues/4264
On my Fedora 23 machine I had to run the following:
sudo dnf install mysql-devel
In CentOS 7 , the following things should be done:
#step1:install mysql
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
#step2:
sudo yum install mysql-devel
or
sudo yum install mysql-community-devel
I think, following lines can be executed on terminal
sudo ln -s /usr/local/zend/mysql/bin/mysql_config /usr/sbin/
This mysql_config directory is for zend server on MacOSx. You can do it for linux like following lines
sudo ln -s /usr/local/mysql/bin/mysql_config /usr/sbin/
This is default linux mysql directory.
I had this issues and solved if by adding a symlink to mysql_config.
I had installed mysql with homebrew and saw this in the output.
Error: The `brew link` step did not complete successfully
Depending on how you got mysql it will be in different places. In my case /usr/local/Cellar/mysql
Once you know where it is you should be able to ma a symbolic link to where python is looking for it. /usr/local/mysql
This worked for me.
ln -s /usr/local/Cellar/mysql/<< VERSION >>/bin/mysql_config /usr/local/mysql/bin/mysql_config
I had the same problem. I solved it by following this tutorial to install Python with python3-dev on Ubuntu 16.04:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y python3-pip
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
And now you can set up your virtual environment:
sudo apt-get install -y python3-venv
pyvenv my_env
source my_env/bin/activate
also, i fetch the same problem
I fixed this problem with the following steps:
First I run this command
sudo apt-get install libmysqlclient-dev
then I install
pip install mysqlclient==2.1.0
this is worked for me
You need to install the python-dev package:
sudo apt-get install python-dev
sudo apt-get install python-mysqldb
Python 2.5? Sounds like you are using a very old version of Ubuntu Server (Hardy 8.04?) - please confirm which Linux version the server uses.
python-mysql search on ubuntu package database
Some additional info:
From the README of mysql-python -
Red Hat Linux
.............
MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
includes Fedora Core and Red Hat Enterprise Linux. You can also
build your own RPM packages as described above.
Debian GNU/Linux
................
Packaged as python-mysqldb_::
# apt-get install python-mysqldb
Or use Synaptic.
.. _python-mysqldb: http://packages.debian.org/python-mysqldb
Ubuntu
......
Same as with Debian.
Footnote: If you really are using a server distribution older than Ubuntu 10.04 then you are out of official support, and should upgrade sooner rather than later.
This method is only for those who know that Mysql is installed but still mysql_config can't be find. This happens if python install can't find mysql_config in your system path, which mostly happens if you have done the installation via .dmg Mac Package or installed at some custom path. The easiest and documented way by MySqlDB is to change the site.cfg. Find the mysql_config which is probably in /usr/local/mysql/bin/ and change the variable namely mysql_config just like below and run the installation again. Don't forget to un-comment it by removing "#"
Change below line
"#mysql_config = /usr/local/bin/mysql_config"
to
"mysql_config = /usr/local/mysql/bin/mysql_config"
depending upon the path in your system.
By the way I used python install after changing the site.cfg
sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py install
So far, all solutions (Linux) require sudo or root rights to install .
Here is a solution if you do not have root rights and without sudo. (no sudo apt install ...):
Download the .deb file of the libmysqlclient-dev, e.g. from this mirror
Navigate to the downloaded file and run dpkg -x libmysqlclient-dev_<version tag>.deb . This will extract a folder called usr.
Symlink ./usr/bin/mysql_config to somewhere that is found on your $PATH:
ln -s `pwd` /usr/bin/mysql_config FOLDER_IN_YOUR_PATH
It should now be able to find mysql_config
Tested on Ubuntu 18.04.
For macOS Mojave , additional configuration was required, for compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
I encountered the same problem, just added the path where *mysql_config* resided to the environment variable PATH and it worked for me.
sudo apt-get build-dep python-mysqldb will install all the dependencies to build the package from PIP/easy_install

(ONIE) stg: command not found and Error 127 in Ubuntu terminal

I was trying to follow this guide: https://github.com/opencomputeproject/onie/blob/master/machine/kvm_x86_64/INSTALL but have gotten stuck.
On this line: make MACHINE=kvm_x86_64 all, I get stg: command not found when it is trying to apply a patch. I get Error 127 on a make command. Here's the output:
I have g++ and git installed. What am I doing wrong?
From the ONIE project wiki Building ONIE:
For a Debian-based system, a Makefile target exists that installs the required packages on your build machine. The ONIE project will maintain this target for the current stable version of Debian. This target requires the use of sudo(8), since package installation requires root privileges:
$ cd build-config
$ sudo apt-get update
$ sudo apt-get install build-essential
$ make debian-prepare-build-host
I built this on Ubuntu Desktop 15.04. For anyone else trying to build ONIE virtual machine, install these packages first:
Packages
qemu-kvm
git
stg
gperf
bison
flex
autoconf
texinfo
gawk
libtool
libtool-bin
libncurses5-dev
libexpat1
libexpat1-dev
python2.7-dev
python3.4-dev
xorriso
You can install most of these with sudo apt-get install <package>. You should be able to follow the ONIE guide now and set it up. Thanks to EtanReisner for all the help!
On Ubuntu, install stg package by,
sudo apt-get install stgit
the error stg: command not found should be resolved.

How to install python3.4 in home 'not root'? ensurepip failure

I do not have root privileges on the Red Hat Linux machine I am installing python3.4 on.
Downloaded Python-3.4.1.tgz
tar -xzf Python-3.4.1.tgz
./configure
makealtinstall --with-ensurepip=install prefix=~ exec-prefix=~
Python3 does install, but I don't have pip.
I get the following error:
Ignoring ensurepip failure: pip 1.5.6 requires SSL/TLS
I don't have root access so I cannot install via:
sudo apt-get install libssl-dev openssl
I do have a working version of openssl.
Does anyone have suggestions I could try?
Since you are in RedHat, you have to install openssl-devel
yum install openssl-devel
Or you can install it later with get-pip.py
The complete procedure for installing Python 3.4 with pip3/pip3.4 on RHEL7 is below. For Ubuntu 12.04 LTS replace yum with apt-get, openssl-devel with libssl-dev and you are good to go:
sudo yum install -y gcc make openssl-devel openssl
wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
tar -xf Python-3.4.3.tgz
cd Python-3.4.3/
./configure --with-ensurepip=install
make
make install
Alternatively, you can run make altinstall depending on whether you need create python link or not.

Boost Installation

I have a question regarding the installation of the boost libraries. Is there a package that I can use the sudo apt-get install to install this package. I searched all of the questions in this forum and using the commands sudo apt-get install libboost1.40-dev I cannot install theh package with this. Also, I can download it from boost.org but I do not know the correct path to install it too. I would prefer to install it using the sudo apt-get install commands if possible. I am using Ubuntu 9.04.
Thanks.
If you want to run with the latest version, you can do the bjam install as mentioned by Ralf, but I suggest you build a 'pseudo' package so you can
uninstall it safely
prevent/notice conflicts with official/existing boost packages.
Here is how to do that:
mkdir -pv /tmp/boostinst
cd /tmp/boostinst/
wget -c 'http://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2/download'
tar xf download
cd boost_1_66_0/
./bootstrap.sh --help
./bootstrap.sh --show-libraries
./bootstrap.sh
checkinstall ./b2 install
On new boost version there is other way:
sudo apt-get update
wget -c 'http://sourceforge.net/projects/boost/files/boost/1.50.0/boost_1_50_0.tar.bz2/download'
tar xf download
cd boost_1_50_0
./bootstrap.sh
./b2 install
You can use command aptitude search libboost to see list of the availiable boost libraries. The last version of boost is 1.42 - maybe that's why you can't find version 1.40.
If aptitude search command don't give you sufficient results, try sudo aptitude update and then run aptitude search again.
On my version of Ubuntu (10.04) it's libboost1.40-all-dev
On your version you've probably got an older version of boost, you should just be able to tab-complete to see which version you can install.
In any case what I usually do under Ubuntu is
sudo apt-get install bjam
Extract the downloaded boost archive to your hard-drive and then cd into the root and
sudo bjam install
This way you can get the newest version of boost, and not the slightly outdated one that is available for your Ubuntu version.
This is a link which explain step by step on how to install it (give it some time read!)
http://www.boost.org/doc/libs/1_41_0/more/getting_started/unix-variants.html
but your inline shell command might be the simple and easy way for doing it

Resources