I have installed openssl version 1.1.1 on RHEL 7.9
and I am running the following commands
./configure --with-openssl=/opt/python/ssl --with-openssl-rpath=auto
make -j8
My gcc version is:
gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am seeing this output.
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
Could not import runpy module
Traceback (most recent call last):
File "/tmp/Python-3.10.9/Lib/runpy.py", line 15, in <module>
import importlib.util
File "/tmp/Python-3.10.9/Lib/importlib/util.py", line 14, in <module>
from contextlib import contextmanager
File "/tmp/Python-3.10.9/Lib/contextlib.py", line 4, in <module>
import _collections_abc
SystemError: <built-in function compile> returned NULL without setting an exception
generate-posix-vars failed
Related
I'm using msal-extensions which uses the gi python package. when running the code I'm getting the following error
Require a package "gir1.2-secret-1" which could be installed by:
sudo apt install gir1.2-secret-1
Traceback (most recent call last):
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/msal_extensions/libsecret.py", line 34, in <module>
gi.require_version("Secret", "1") # Would require a package gir1.2-secret-1
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/gi/__init__.py", line 126, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Secret not available
Using Vault URI
but when I run
sudo apt list | grep gir1.2-secret-1
WARNING: apt does not have a stable CLI interface. Use caution in scripts.
gir1.2-secret-1/bionic,now 0.18.6-1 amd64 [installed]
I see it's installed. I'm not sure why the python code does not recognize gir1.2-secret-1
Im using Linux compnode03 5.4.0-1056-azure #58~18.04.1-Ubuntu SMP Wed Jul 28 23:14:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Any ideas?
Trying to install a new Python - version with pyenv on Ubuntu 20.04 WSL for Windows 10 fails with the following output:
username#hd1pcms0347:~$ pyenv install 3.9.4
Downloading Python-3.9.4.tar.xz...
-> https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
Installing Python-3.9.4...
python-build: use readline from homebrew
BUILD FAILED (Ubuntu 20.04 using python-build 20180424)
Inspect or clean up the working tree at /tmp/python-build.20210602162502.2268
Results logged to /tmp/python-build.20210602162502.2268.log
Last 10 log lines:
File "/tmp/python-build.20210602162502.2268/Python-3.9.4/Lib/ensurepip/__init__.py", line 210, in _main
return _bootstrap(
File "/tmp/python-build.20210602162502.2268/Python-3.9.4/Lib/ensurepip/__init__.py", line 129, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/tmp/python-build.20210602162502.2268/Python-3.9.4/Lib/ensurepip/__init__.py", line 38, in _run_pip
return subprocess.run([sys.executable, "-c", code], check=True).returncode
File "/tmp/python-build.20210602162502.2268/Python-3.9.4/Lib/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/python-build.20210602162502.2268/Python-3.9.4/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmp7aa5f7ml/setuptools-49.2.1-py3-none-any.whl\', \'/tmp/tmp7aa5f7ml/pip-20.2.3-py2.py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp7aa5f7ml\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [Makefile:1255: install] Error 1
EDIT:
I had shared the log file earlier via GoogleDrive so that #Marlon Richert could give his nice answer based on its contents.
These are the relevant parts of your log:
In file included from /tmp/python-build.20210602162502.2268/Python-3.9.4/Modules/_cursesmodule.c:113:
./Include/py_curses.h:36:10: fatal error: curses.h: No such file or directory
36 | #include <curses.h>
| ^~~~~~~~~~
compilation terminated.
[...]
/tmp/python-build.20210602162502.2268/Python-3.9.4/Modules/_ctypes/_ctypes.c:107:10: fatal error: ffi.h: No such file or directory
107 | #include <ffi.h>
| ^~~~~~~
compilation terminated.
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _curses_panel _dbm
_gdbm _lzma _sqlite3
_tkinter _uuid zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc atexit pwd
time
Failed to build these modules:
_ctypes _curses
[...]
Traceback (most recent call last):
File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 568, in _get_data
File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
It looks like you're missing the dependencies that PyEnv requires for building Python. Since you're using Ubuntu, run the following:
sudo apt update
sudo apt install \
build-essential \
curl \
libbz2-dev \
libffi-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxmlsec1-dev \
llvm \
make \
tk-dev \
wget \
xz-utils \
zlib1g-dev
Then try again.
I had the same issue on Fedora 36 (no wsl, running as main OS) after installing pyenv via pyenv-installer and like marlon's answer ( https://stackoverflow.com/a/67853440 ) it turned out to be a combination of missing dependencies from looking at the log file. What resolved it for me was
sudo dnf install ffi
sudo dnf install ffi-devel
sudo dnf install zlib
sudo dnf install zlib-devel
After that, python will install (e.g. via pyenv install 3.10.7) but you need install other libraries based on the warnings it gives. for example after installation the warnings I got was:
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python curses extension was not compiled. Missing the ncurses lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
WARNING: The Python tkinter extension was not compiled and GUI subsystem has been detected. Missing the Tk toolkit?
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
obviously, follow the rest of Marlon's answer and install all the dependencies listed on https://github.com/pyenv/pyenv/wiki#suggested-build-environment
Upon attempting to compile python 3.7 I hit Could not import runpy module:
jeremyr#b88:$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
....
jeremyr#b88:~/Python-3.7.3$ ./configure --enable-optimizations
jeremyr#b88:~/Python-3.7.3$ make clean
jeremyr#b88:~/Python-3.7.3$ make -j32
....
gcc -pthread -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.7m.a -lcrypt -lpthread -ldl -lutil -lm
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
Could not import runpy module
Traceback (most recent call last):
File "/home/jeremyr/Python-3.7.3/Lib/runpy.py", line 15, in <module>
import importlib.util
File "/home/jeremyr/Python-3.7.3/Lib/importlib/util.py", line 14, in <module>
from contextlib import contextmanager
File "/home/jeremyr/Python-3.7.3/Lib/contextlib.py", line 4, in <module>
import _collections_abc
SystemError: <built-in function compile> returned NULL without setting an error
generate-posix-vars failed
Makefile:603: recipe for target 'pybuilddir.txt' failed
make[1]: *** [pybuilddir.txt] Error 1
make[1]: Leaving directory '/home/jeremyr/Python-3.7.3'
Makefile:531: recipe for target 'profile-opt' failed
make: *** [profile-opt] Error 2
jeremyr#88:~/Python-3.7.3$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.11 (jessie)
Release: 8.11
Codename: jessie
jeremyr#88:~/Python-3.7.3$ gcc --version
gcc (Debian 4.9.2-10+deb8u2) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
jeremyr#88:~/Python-3.7.3$ sudo apt upgrade gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... gcc is already the newest version.
jeremyr#b88:~/Python-3.7.3$ echo $PYTHONPATH
Any advice on how to overcome this and install python3.7 appreciated.
Edit - the solution listed below seems to work for various other python versions, so I changed title to python 3.x from 3.7
It seems the enable-optimizations was the problem,
jeremyr#b88:~/Python-3.7.3$ ./configure
jeremyr#b88:~/Python-3.7.3$ make clean
takes care of it in my case.
In case others come across this question: I encountered the same problem on Centos 7. I also had --enable-optimizations but didn't want to remove that flag. Updating my build dependencies and then re-running solved the problem. To do that I ran:
sudo yum groupinstall "Development Tools" -y
In case the yum group is not available, you can also install the pacakges individually using:
sudo yum install bison byacc cscope ctags cvs diffstat doxygen flex gcc gcc-c++ gcc-gfortran gettext git indent intltool libtool patch patchutils rcs redhat-rpm-config rpm-build subversion swig systemtap
For whomever MicGer's answer didn't work and would like to retain --enable-optimizations, check your gcc version. The error was solved for me on gcc 8.3.0.
For me, CentOS 7, compiling Python3.9, the fix was updating the gcc and related packages.
Removing --enable-optimizations didn't solved the issue here, neither upgrading GCC from gcc-7.5.0 to gcc-8.2.1 trying building Python 3.6.13 on opensuse-15.2.
Here for some reason the build is picking a local python installation, so before calling make I have updated the PATH env to include the build directory (were python file is generated), for instance: export PATH=$(pwd):$PATH
I am trying to compile python-mysqlclient against mariadb-connector-c in a Conda environment. That means that the install prefix is not /usr/local but, for example, $HOME/conda/envs/test. I also want to use the auth_gssapi_client.so plugin.
Both packages build, but import MySQLdb raises the following exception:
Traceback (most recent call last):
File "/opt/emsconda/conda-bld/env/test_tmp/run_test.py", line 2, in <module>
import MySQLdb
File "/opt/emsconda/conda-bld/env/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmariadb.so.3: cannot open shared object file: No such file or directory
The reason for this is that mysqlclient only searches lib/ but not
lib/mariadb even though it was configured with the right path and sucessfully
built. I can work around this issue by copying the *.so files to lib/ (or
by creating a symlink), but then, it does not find the GSSAPI plugisn …
I build mariadb-connector-c 3.0.2 this way:
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release ..
make
make install
I can install it and run mariadb_config which gives this output:
Copyright 2011-2015 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: /opt/emsconda/conda-bld/mysqlclient_1510048680472/_h_env/bin/mariadb_config [OPTIONS]
--cflags [-I/opt/emsconda/conda-bld/env/include/mariadb -I/opt/emsconda/conda-bld/env/include/mariadb/mysql]
--include [-I/opt/emsconda/conda-bld/env/include/mariadb -I/opt/emsconda/conda-bld/env/include/mariadb/mysql]
--libs [-L/opt/emsconda/conda-bld/env/lib/mariadb/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto]
--libs_r [-L/opt/emsconda/conda-bld/env/lib/mariadb/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto]
--libs_sys [-lpthread -ldl -lm -lssl -lcrypto]
--version [10.2.6]
--socket [/tmp/mysql.sock]
--port [3306]
--plugindir [/opt/emsconda/conda-bld/env/lib/mariadb/plugin]
--tlsinfo [OpenSSL 1.0.2k]
I then build python-mysqlclient 1.3.12 this way:
MYSQL_CONFIG="$PREFIX/bin/mariadb_config"
echo "mysql_config = $PREFIX/bin/mariadb_config" >> site.cfg
$PYTHON -m pip install -I --no-deps .
There are two possible solutions for this problem:
Configure mariadb-connector-c to directly put its stuff into lib/ – I have not found documentation on how to do this.
Make python-mysqlclient respect the paths that mariadb_config returns – How?
You have to statically link the gssapi stuff into mariadb-connector-c and Python mysqlclient will work.
This is how to build mariadb-connector-c:
mkdir build
cd build
cmake \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DINSTALL_LIBDIR=lib \
-DINSTALL_PLUGINDIR=lib/plugin \
-DWITH_MYSQLCOMPAT=ON \
-DAUTH_GSSAPI=STATIC \
-DCMAKE_BUILD_TYPE=Release \
..
make
make install
# WITH_MYSQLCOMPAT only creates links for the libs, not for the binary:
cd $PREFIX/bin
ln -s mariadb_config mysql_config
I am new to docker and would appreciate if someone can help me get rid of this error while building the docker image. It is giving some kind of locale error. How can I get rid of this error ?
Collecting pip
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
Collecting setuptools
Downloading setuptools-20.3.1-py2.py3-none-any.whl (508kB)
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-8.1.1 setuptools-20.3.1 wheel-0.29.0
+ pip install --no-cache-dir --upgrade pip==8.0.2
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in
sys.exit(main())
File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib64/python2.7/locale.py", line 547, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
The command '/bin/sh -c set -ex && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 && pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION' returned a non-zero code: 1
This is my Dockerfile:
FROM mybase:1.0.7
RUN set -x \
&& yum install -y python-devel libffi-devel python-cffi \
&& yum clean all
ENV LANG C.UTF-8
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
ENV PYTHON_VERSION 2.7.11
ENV PYTHON_PIP_VERSION 8.0.2
RUN set -ex \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
&& curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION
RUN pip install --no-cache-dir virtualenv
CMD ["python2"]
The locale.setlocale docs say the locale should be valid. If an empty string is passed, the LANG variable is used to set the locale. This error is probably caused because your LANG is not a supported locale
In your docker script, you set LANG to C.UTF-8. It looks like C.UTF-8 is not a supported locale in glibc and I am guessing hence in Python (See this and this).
You can set your LANG to a supported type like en_US.UTF-8 (The default on my computer).
On Python-2.6, I get the following results
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
'en_US.utf8'
>>> locale.setlocale(locale.LC_ALL, "C.UTF-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/locale.py", line 513, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
'en_US.UTF-8'
>>> locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
'de_DE.UTF-8'
You can view the locales available on your computer by running
$ locale -a