Problems installing python package

I am attempting to install the python API as per the instructions here https://docs.couchbase.com/python-sdk/current/start-using-sdk.html. These suggest the package should have all dependencies included, but the output suggests this is not the case.

On windows (python 2.7)

C:\Python27>pip install couchbase
Collecting couchbase
  Using cached https://files.pythonhosted.org/packages/e6/a4/a9f4a590abf00cd721d446a2096a1f366de2f2212bfd064dc8cc54ac7676/couchbase-2.5.4.tar.gz
  Ignoring pip: markers '(sys_platform != "win32" and python_version >= "2.7") or python_version >= "3.0"' don't match your environment
Requirement already satisfied: typing in c:\python27\lib\site-packages (from couchbase)
Installing collected packages: couchbase
  Running setup.py install for couchbase ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\towler\\appdata\\local\\temp\\pip-build-vc0gyw\\couchbase\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\towler\appdata\local\temp\pip-qp_cff-record\install-record.txt --single-version-externally-managed --compile:
    c:\users\towler\appdata\local\temp\pip-build-vc0gyw\couchbase\setup.py:111: UserWarning: I'm detecting you're running windows.You might want to modify the 'setup.py' script to use appropriate paths
      warnings.warn("I'm detecting you're running windows."
    running install
    running build
    running build_py
    creating build\lib.win32-2.7

…
C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D_CRT_SECURE_NO_WARNINGS=1 -I…\lcb-winbuild\x86\deps\include -Ic:\python27\include -Ic:\python27\PC /Tcsrc\exceptions.c /Fobuild\temp.win32-2.7\Release\src\exceptions.obj
exceptions.c
c:\users\towler\appdata\local\temp\pip-build-vc0gyw\couchbase\src\pycbc.h(193) : fatal error C1083: Cannot open include file: β€˜libcouchbase/couchbase.h’: No such file or directory
error: command β€˜C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe’ failed with exit status 2

----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\towler\\appdata\\local\\temp\\pip-build-vc0gyw\\couchbase\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\towler\appdata\local\temp\pip-qp_cff-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\towler\appdata\local\temp\pip-build-vc0gyw\couchbase\

The experience on centos 7 is much the same

(couchbase)towler@buildlocal:~$ pip install couchbase
You are using pip version 7.1.0, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting couchbase
  Downloading https://files.pythonhosted.org/packages/e6/a4/a9f4a590abf00cd721d446a2096a1f366de2f2212bfd064dc8cc54ac7676/couchbase-2.5.4.tar.gz (647kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 651kB 335kB/s
Collecting typing (from couchbase)
  Downloading https://files.pythonhosted.org/packages/cc/3e/29f92b7aeda5b078c86d14f550bf85cff809042e3429ace7af6193c3bc9f/typing-3.6.6-py2-none-any.whl
Building wheels for collected packages: couchbase
  Running setup.py bdist_wheel for couchbase
  Complete output from command /home/towler/couchbase/bin/python2 -c "import setuptools;__file__='/tmp/pip-build-NBNCzG/couchbase/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpAdqvSfpip-wheel-:
  running bdist_wheel
...
building 'couchbase._libcouchbase' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/rh/python27/root/usr/include/python2.7 -c src/exceptions.c -o build/temp.linux-x86_64-2.7/src/exceptions.o
In file included from src/exceptions.c:17:0:
src/pycbc.h:193:10: fatal error: libcouchbase/couchbase.h: No such file or directory
 #include <libcouchbase/couchbase.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/home/towler/couchbase/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-NBNCzG/couchbase/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3PVDQT-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/towler/couchbase/include/site/python2.7/couchbase" failed with error code 1 in /tmp/pip-build-NBNCzG/couchbase

Hi

Please follow the detailed instructions on the page you linked.

On Unix based systems, you need to install libcouchbase to build Couchbase Python Client V2. We have developed a system for building all necessary dependencies for our upcoming V3 Alpha but that is pending release.

On Windows, we only support Python>3.6 (see https://docs.couchbase.com/python-sdk/current/compatibility-versions-features.html), but you should be able to run β€˜pip install couchbase’ and Pip will pull in a wheel with all the necessary dependencies.

Hope that helps,

Thanks,

Ellis

Thanks for the quick reply, I now have this working on windows.

Having searched the page I suggest it might be helpful for others if the page I linked to could gain a mention of either the minimum python version or a link to a page listing this. I searched for both β€œ3” and β€œplatform” and found no results.

1 Like

Hi Towler,

No problem. Glad to hear we got you up and running!

Thanks for your feedback re the documentation - I will file a documentation issue to make the requirements clearer.

Thanks,

Ellis

https://issues.couchbase.com/browse/DOC-5337 - update submitted. Thanks :slight_smile:

For Ubuntu Users:

Please try

apt-get install build-essential python-dev python-pip

And Run

pip install couchbase

Hi @Nikhil_MVS - Thanks for the additional comments!

I wanted to also point out that we have been able to update the documentation with further details on installing. Both the Couchbase documentation and the Github README reflect details on how to install the Python SDK on various OSes.

I hope this helps.