Top 60 Oracle Blogs

Recent comments

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
Python 3.43

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
Yep, do what it says and as SUDO, (Super User Domain Owner) use APT-GET, (this is Ubuntu, but if it’s another Linux distribution, you may need to use YUM or ZYPPER) to install pip!

Failure in pip Install for Python3

If it succeeded, you’re set and you can go forward, if you attempt to install PIP, but receive the following error at the end of the installation:
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-pip (--configure):
If you scan up in the installation process, you’ll see errors similar to the following:
dpkg: error processing package python-pip (--configure):
storing debug log for failure in /root/.pip/pip.log
Many errors will be trapped to the pip.log.  For these types of errors, they are commonly unique and the application installation will log them and you must go look to see the exact problem. For this one, we have separate problem.  The ConfigParser was replaced by the configparser in Python3.  It’s not actually the PIP install that’s having a problem, but another support utility that is on a too early of a version.
view /root/.pip/pip.log
If it is only the ConfigParser error in Python3, (unlike Python 2.7, which I’ll discuss later on) do the following:
Run an update for the available packages:
sudo apt-get update
Update the Net-Tools and the Setup Tools:
sudo apt-get install net-tools

sudo apt-get install setuptools
Attempt to run the installation again and verify that the config parser error is fixed, as the dependent utilities are now pointing to the correct support utilities, too.
sudo apt-get install python3-pip

Dependencies Upon Dependencies

All of these challenges surrounds dependencies for mssql-cli for libraries, utilities and packages that aren’t present on your Linux host/image.  Once you correct one, it doesn’t mean you are done, it means you may have to fix others and the correct step once you correct everything is to create an image for your database server so you don’t have to run through this every time.
The next set of errors once you get through the last one, when installing the mssql-cli may include the following:
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
#ff0000;">E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
You’ll need to run this as SUDO again, as you’re admin won’t have the privileges required to run this by default.  The installer is clearly telling you that you are missing a number of distribution python library files/packages that are needed before you can run this step, so, run the update to gather the latest from the repository:
sudo apt-get -f install
Then run the python installation again:
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]
This may be a false failure.  It can’t stop the landscape-client daemon because IT ISN’T INSTALLED.
1.  Verify if it exists:
ps -ef | grep daemon
This will display a list of all running daemons.  If you don’t see the landscape-client in the list, you can switch over to ROOT, (the proper owner) and see if it can be started with the minimum command:
sudo su -

If it says it isn’t installed, you’re good.  You’ve just verified that the reason the step failed in the install was the landscape-client isn’t installed in the first place.

Failure to Create the Setup Tools

You’ve run the installer without checking the version of Python and run into this error:
    Installed /tmp/pip_build_azureuser/pymssql/setuptools_git-1.2-py2.7.egg

Installing collected packages: mssql-cli, pymssql
Running install for mssql-cli
#ff0000;">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/';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:
This is actually part of the final failure that you’ll see if you’re attempting to install the mssql-cli with the wrong Python version set.  You should note the 2.7 version in the path and the continued failures due to missing library and module files.

Fix the Version of Python

Yes, it’s Python and without the right support version, it’s going to have some issues.  The errors that you receive may become a bit misleading because you’ll see the demands for pymssql or other modules that are no longer available:
#ff0000;">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:

Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/pymssql/';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
1.  Determine “which” Python you are pointed to, ensuring that nothing in your path has redirected you to a different version of Python than the default one in /usr/bin:
which python
Now find out what the soft link looks like:
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

As you update the installation libraries to be then installed on your Linux VM, keep in mind, this is simply adding them to the repository to be available and only required ones will be added if you run the “sudo apt-get install” command afterwards.  No secondary libraries or tools will be installed until you call them specifically.  If it’s been awhile since you’ve updated your repository for newly available updates or you just built the image, it’s a good idea to run an update and install overall.  Once this is done, then run the pip installation:
sudo apt-get update

sudo apt-get -f install
sudo apt-get install python-pip
TypeError: #ff0000;">Error when calling the metaclass bases

    str() takes at most 1 argument (3 given)

Cleaning up...
Command python egg_info failed with error code 1 in /tmp/pip_build_root/pymssql
Storing debug log for failure in /root/.pip/pip.log
Let’s get this fixed by updating the setup tools and then running the installation again:
pip install --upgrade setuptools
There may be a next layer to this error:
  File "/tmp/pip_build_root/pymssql/", line 88, in 

    from Cython.Distutils import build_ext as _build_ext

ImportError: #ff0000;">No module named Cython.Distutils

Cleaning up...
Command python egg_info failed with error code 1 in /tmp/pip_build_root/pymssql
Storing debug log for failure in /root/.pip/pip.log
Notice that there is a debug log included in this, as the error can be different for each failure.  View the log for more information:
view /root/.pip/pip.log
If you run into this one, feel free to put the exact error from the pip.log into the comments and we’ll work through it.

When Cython Fails

Note in the error, we are missing the Cython.Distutils.  Cython is considered the superset of the Python language, so yes, we need this to work.  As we install missing libraries and utilities/tools,  we may need to follow back through and repeat other installations, library–> tool–>application that was the goal to begin with.  To install this, the following command(s) can be run as one with the following set, separated by a semi-colon:
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 "#ff0000;">/usr/lib/python3/dist-packages/", 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:


sudo python

pip --version

Trick the Pip

What ended up working to get mssql-cli for many was to trip the PIP installation by installing the python 3 pip, copying over the pip from 2.7 to it, then installing the full setup tools to correct whatever appears to be incomplete in the 3 version in some repositories.
sudo easy_install3 pip

sudo mv /usr/local/bin/pip /usr/local/bin/pip-3
Run the installation another time:
sudo apt-get install python3-setuptools
Now run the mssql-cli install:
sudo pip install mssql-cli

Last Error I’ll Cover, I Promise!

Although you’re able to install mssql-cli now, you may experience one more error in the variations of this troubleshooting guide:
  Building wheel for terminaltables ( ... 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.
The prompt toolkit is just as it sounds-  it’s a powerful toolkit to build out command line and terminal applications.  If you want to update this, as the one in the image may be an earlier than supported version, you can update your net-tools package, which includes a newer version of the prompt-toolkit:
sudo apt-get install net-tools
This should be all of the related challenges that you could run into with installing mssql-cli on Ubuntu Linux.
Hope it’s helpful!!


Tags:  , ,





Copyright ©  [Failed Installation of MSSQL-CLI on Ubuntu], All Right Reserved. 2020.