Failed Installation of MSSQL-CLI on Ubuntu
So you want to run mssql-cli on Ubuntu Linux, but you received a number of errors and even if you got through some errors, you’re still stuck?
I’m here to try to help you get through them and hopefully I’ve captured them all. Trust me, the Oracle DBAs have been here- our databases and tools failed for a very long time until Linux administrators came to know what we needed and started to build us the images with the correct libraries and versions we needed, so we feel your pain!
The easiest scenario for many to deploy SQL Server 2019 on Linux to start working with it, is most likely an Ubuntu distribution, (flavor) of Linux. With that, you may want to play with the newest tool for command line execution of SQL, which isn’t sqlcmd, but mssql-cli. It’s got some awesome new features, which I won’t go into here, but focus on installation failures instead, which happens not because the installation is complicated but because of the demands still for Python 2.7 when 3+ versions are required for newer software.
mssql-cli requires Python 3, so I recommend checking the version before running the mssql-cli installation command, as this may save you a lot of work with dependencies. I’ll still go through the steps to if you want to force it to work with Python 2.7, but seriously, just using the right version of Python will make it so much easier.
python3 --version
PIP Isn’t Installed
pip install mssql-cli
The program ‘pip’ is currently not installed. You can install it by typing:
sudo apt-get install python3-pip
Failure in pip Install for Python3
ImportError: No module named 'ConfigParser' dpkg: error processing package python-pip (--configure):
dpkg: error processing package python-pip (--configure):
storing debug log for failure in /root/.pip/pip.log
view /root/.pip/pip.log
sudo apt-get update
sudo apt-get install net-tools sudo apt-get install setuptools
sudo apt-get install python3-pip
Dependencies Upon Dependencies
The following packages have unmet dependencies:
openssl : Depends: libssl1.0.0 (>= 1.0.2g) but 1.0.1f-1ubuntu2.27 is to be installed
python-pip : Depends: python-colorama but it is not going to be installed
Depends: python-distlib but it is not going to be installed
Depends: python-html5lib but it is not going to be installed
Depends: python-pip-whl (= 1.5.4-1ubuntu4) but it is not going to be installed
Depends: python-setuptools (>= 0.6c1) but it is not going to be installed
Recommends: build-essential but it is not going to be installed
Recommends: python-dev-all (>= 2.6) but it is not installable
Recommends: python-wheel but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
sudo apt-get -f install
sudo apt-get install python-pip
Failure Restarting the Daemon
Upon installion, post the update, you may also receive a failure step when attempting to restart the daemon:
Removing landscape-client (14.12-0ubuntu6.14.04.4) ... * Stopping landscape-client daemon [fail]
ps -ef | grep daemon
sudo su - landscape-client
Failure to Create the Setup Tools
Installed /tmp/pip_build_azureuser/pymssql/setuptools_git-1.2-py2.7.egg
Installing collected packages: mssql-cli, pymssql
Running setup.py install for mssql-cli
error: could not create '/usr/local/lib/python2.7/dist-packages/mssql_cli': Permission denied
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_azureuser/mssql-cli/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-46EYHL-record/install-record.txt --single-version-externally-managed --compile:
Fix the Version of Python
DeprecationWarning: The pymssql project has been discontinued. To install the last working released version, use a
version specifier like "pymssql<3.0". For details and alternatives see:
https://github.com/pymssql/pymssql/issues/668
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ccg8po-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/pymssql
Storing debug log for failure in /home/azureuser/.pip/pip.log
which python /usr/bin/python
ls -la /usr/bin/python lrwxrwxrwx 1 root root 18 Nov 22 21:22 /usr/bin/python -> /usr/bin/python2.7
You'll need to remove the existing soft link, (remember, this is just a soft link, you aren't removing Python.) and then create a new one. This should be done as the root user: rm /usr/bin/python ln -s /usr/bin/python3.4 /usr/bin/python
Now run your installation and this should fix many of the issues that you may have been facing. If not, continue on with the steps and learn how to address dependencies.
sudo pip install mssql-cli
Update and Install
sudo apt-get update sudo apt-get -f install
sudo apt-get install python-pip
TypeError: Error when calling the metaclass bases
str() takes at most 1 argument (3 given)
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/pymssql
Storing debug log for failure in /root/.pip/pip.log
pip install --upgrade setuptools
File "/tmp/pip_build_root/pymssql/setup.py", line 88, in <module>
from Cython.Distutils import build_ext as _build_ext
ImportError: No module named Cython.Distutils
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/pymssql
Storing debug log for failure in /root/.pip/pip.log
view /root/.pip/pip.log
When Cython Fails
sudo apt-get install python-dev; sudo pip install cython
Update the setup tools
pip install --upgrade setuptools pip
Use a different driver, as the pymsql driver is no longer supported through it’s github repository:
pip install sqlalchemy_pyodbc_mssql
You should be set now to install msql-cli
sudo pip install mssql-cli
Pip Install not Found
PIP is a command line tool to install Python software packages and is required to perform the mssql-cli installation. If the wrong version for support or soft links, (think of them as aliases in Linux) are pointing to the wrong directories/library files, a failure will occur. This can become a frustrating situation, so I’m hoping to walk you through errors and fixes. Keep in mind, as you go through these fixes, you may have to re-run previous commands to success once you fix each dependency.
If you receive the following error:
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 628, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.5.4
This is due to a pip installation for 2.7 of Python that needs to be installed to the 3.4 version and relinked. This can be done with the following commands:
wget https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py pip --version
Trick the Pip
sudo easy_install3 pip sudo mv /usr/local/bin/pip /usr/local/bin/pip-3
sudo apt-get install python3-setuptools
sudo pip install mssql-cli
Last Error I’ll Cover, I Promise!
Building wheel for terminaltables (setup.py) ... done Stored in directory: /root/.cache/pip/wheels/30/6b/50/6c75775b681fb36cdfac7f19799888ef9d8813aff9e379663e Successfully built configobj humanize future terminaltables ERROR: prompt-toolkit 2.0.10 has requirement six>=1.9.0, but you'll have six 1.5.2 which is incompatible.
sudo apt-get install net-tools
Pingback: When mssql-cli Installation Fails on Ubuntu – Curated SQL