I am looking to install Python 3.10.9 and some packages behind a firewall on RHEL 7 machine.
I do not have administrative rights, nor access to elevated privileges. Some core requirements are missing to build items from source. I've been unable to build with OpenSSL, and thus can't pip install packages.
I prefer to stick to packaged solutions as much as possible, so I've pursued a path that allows installing dependencies with yum.
Relevant related questions
Preparing _tkinter and sqlite3 for Python installation (no admin rights)
Relevant lessons: How to install packages in Linux (CentOS) without root user with automatic dependency handling?
# Install prerequisites
mkdir ~/rpm
mkdir ~/rhel
yumdownloader --destdir ~/rpm --resolve zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel libffi
cd ~/rhel && for i in ~/rpm/*.rpm; do rpm2cpio $i | cpio -idv; done
# Modify ~/.bashrc with necessary flags and includes. See .bashrc below
source ~/.bashrc
#Download pyenv and install
curl https://pyenv.run | bash
pyenv install 3.10.9
The part I seem to be getting stuck on, is correctly referencing the various libraries that are installed.
Rather than build dependencies from source, utilized yum to install:
Current ~/.bashrc
# For building custom YUM locally
export PATH="$HOME/rhel/usr/sbin:$HOME/rhel/usr/bin:$HOME/rhel/bin:$PATH"
export MANPATH="$HOME/rhel/usr/share/man:$MANPATH"
L='/lib:/lib64:/usr/lib:/usr/lib64'
export LD_LIBRARY_PATH="$HOME/rhel/usr/lib:$HOME/rhel/usr/lib64:$L"
# PyEnv install https://www.mpietruszka.com/install-pyenv-ce-rhel8.html
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
#export PKG_CONFIG_PATH=$HOME/rhel/usr/lib/pkgconfig:$PKG_CONFIG_PATH
#LDFLAGS
export LDFLAGS="-L$HOME/rhel/usr/lib -L$HOME/rhel/usr/lib64 -L/usr/lib -L/usr/lib64 -L/lib -L/lib64"
#CPPFLAGS
export CPPFLAGS="-I$HOME/rhel/usr/lib -I$HOME/rhel/usr/lib64 -I/usr/lib -I/usr/lib64 -I/lib -I/lib64"
#LD_Library
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/rhel/usr/include"
The errors I'm currently getting
pyenv install 3.10.9
Downloading Python-3.10.9.tar.xz...
-> https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tar.xz
Installing Python-3.10.9...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "~/.pyenv/versions/3.10.9/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "~/.pyenv/versions/3.10.9/lib/python3.10/ssl.py", line 99, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
BUILD FAILED (RedHatEnterpriseServer 7.7 using python-build 20180424)
Inspect or clean up the working tree at /tmp/python-build.20230208180402.153250
Results logged to /tmp/python-build.20230208180402.153250.log
Last 10 log lines:
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmp540mosi3
Processing /tmp/tmp540mosi3/setuptools-65.5.0-py3-none-any.whl
Processing /tmp/tmp540mosi3/pip-22.3.1-py3-none-any.whl
Installing collected packages: setuptools, pip
WARNING: The scripts pip3 and pip3.10 are installed in '~/.pyenv/versions/3.10.9/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-22.3.1 setuptools-65.5.0
make: warning: Clock skew detected. Your build may be incomplete.
I'd appreciate some criticism on correctly calling these libraries...
Related
On MacOS there is a homebrew formula to install the RPM development package from rpm5.org. However, this installs only the command line tools (rpm, rpmlint, rpmbuild, etc) and does not install any of the language bindings which are supported.
I would like to use the Pascal language bindings. However, when I build them and attempt to import the rpm package into Python 2.7 I get this error:
$ python -c "import rpm._rpm"
Traceback (most recent call last):
File "", line 1, in
File
"/usr/local/lib/python2.7/venv-default/lib/python2.7/site-packages/rpm/init.py",
line 7, in
from _rpm import * ImportError: dlopen(/usr/local/lib/python2.7/venv-default/lib/python2.7/site-packages/rpm/_rpmmodule.so,
2): Symbol not found: _sqlite3_enable_load_extension Referenced
from: /usr/local/Cellar/rpm/5.4.15_1/lib/librpmio-5.4.dylib Expected
in: flat namespace in
/usr/local/Cellar/rpm/5.4.15_1/lib/librpmio-5.4.dyl
To build the Python bindings I re-installed the rpm package with homebrew using these commands:
brew install -v --keep-tmp --build-from-source rpm 2>&1 | tee brew_install.log
cd /tmp/rpm-20170408-18245-1u8nsbs/rpm-5.4.15
./configure --prefix=/usr/local/Cellar/rpm/5.4.15_1 --localstatedir=/usr/local/var --with-path-cfg=/usr/local/etc/rpm --with-path-magic=/usr/local/share/misc/magic --with-path-sources=/usr/local/var/lib/rpmbuild --with-libiconv-prefix=/usr --disable-openmp --disable-nls --disable-dependency-tracking --with-db=external --with-sqlite=external --with-file=external --with-popt=external --with-beecrypt=internal --with-libtasn1=external --with-neon=internal --with-uuid=external --with-pcre=internal --with-lua=internal --with-syck=internal --without-apidocs varprefix=/usr/local/var --with-python
cd python
make
make install
Note the ./configure command is the same one as Homebrew used with the --with-python switch appended.
How can I use the cross platform rpm5.org based source code to do Python language development on MacOS?
Your error depends on how sqlite3 and rpm are built on OS/X with brew.
sqlite3 can be built to add _sqlite3_enable_load_extension
or RPM can be patched to remove the need for _sqlite3_enable_load_extension .
If patching RPM, see rpmio/rpmsql.c near line 2881.
i am a beginner i need to create a python virtual_environment for installing Django. I am using the following steps for installing python and virtualenv
cd /usr/src/
wget http://www.python.org/ftp/python/3.5.1./Python-3.5.1.tgz
tar zxf Python-3.5.1.tgz
cd python-3.5.1
mkdir /usr/local/python-3.5
./configure --prefix=/usr/local/python'.$python.' --with-threads --enable-shared --with-zlib=/usr/include && make && make altinstall
echo "/usr/local/python3.5/lib" > python3.5.conf
mv python3.5.conf /etc/ld.so.conf.d/python3.5.conf
/sbin/ldconfig
ln -sfn /usr/local/python3.5/bin/python3.5 /usr/bin/python3.5
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.tar.gz
tar xzf setuptools-11.3.1.tar.gz
cd setuptools-11.3.1
/usr/local/python3.5/bin/python3.5 setup.py install
/usr/local/python3.5/bin/easy_install-3.5 pip
ln -sfn /usr/local/python3.5/bin/pip3.5 /usr/bin/pip3.5
/usr/local/python3.5/bin/pip3.5 install virtualenv
then i am created a virtualenv based on this,
and enter into python shell and use
import sqlite
i got following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'sqlite'
And i tried to run a django project installed in the virtalenv i got following errors.
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named '_sqlite3'
I am using CentOS release 6.8 (Final).
The python-bundled sqlite package is called sqlite3:
https://docs.python.org/3.6/library/sqlite3.html
So, just do
import sqlite3
and you should be good.
EDIT
I only now realized that you're building python yourself. So that's probably why the sqlite3 module is missing. Check the output of the configure call whether sqlite3 is mentioned.
I assume you'd have to get the development packages.
Any reason you are not using the EPEL Repository to install python?
I am running Ubuntu 12.10 that has python 2.7 as its default. I have installed python 3.3 in /opt/python3.3 (using ./configure --prefix=/opt/python3.3) and have created a symlink /usr/bin/python33 that points to the executable in /opt. There is already a symlink /usr/bin/python3 that points to the python 3.2 (actually it points to python3.2mu: if you can explain as a side note as to why this 'mu' is included :) ) installation that came with the ubuntu installation.
I installed distribute tools using python3 without any problems. But when I tried the same thing with python33 it gave me the following error:
ankur#junk-mechanism:~$ sudo python33 distribute_setup.py
Extracting in /tmp/tmp685lyf
lzma module is not available
not a bzip2 file
gzip module is not available
bad checksum
Traceback (most recent call last):
File "distribute_setup.py", line 550, in <module>
sys.exit(main())
File "distribute_setup.py", line 547, in main
return _install(tarball, _build_install_args(options))
File "distribute_setup.py", line 78, in _install
tar = tarfile.open(tarball)
File "/opt/python3.3/lib/python3.3/tarfile.py", line 1578, in open
raise ReadError("file could not be opened successfully" + str(name) + repr(fileobj))
tarfile.ReadError: file could not be opened successfully/home/ankur/distribute-0.6.35.tar.gzNone
So in tarfile.py, the classmethod Tarfile.open calls the class method Tarfile.gzopen where the module gzip is imported:
try:
import gzip
gzip.GzipFile
except (ImportError, AttributeError):
raise CompressionError("gzip module is not available")
The error raised here is ImportError because gzip.py has an import zlib which it cant find. But even the other installations of python (2.7 and 3.2) dont contain zlib in the respective standard lib /usr/lib/pythonx.x/lib/. So what is the difference?
It sounds like you didn't build everything because of missing dependencies. You can try getting the missing dependencies and rebuilding. To get the missing dependencies, I'd just work from what Python 3.2 requires and do:
sudo apt-get build-dep python3
Then you can reconfigure and rebuild Python 3.3 to get all the required modules.
Another option is to use the dead snakes ppa:
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3
I usually install the -dev package too so that I can install packages that have C extension modules:
sudo apt-get install python3.3-dev
There might be other questions similar to this but, in my particular case, I don't have super user (sudo) access to the machine and I have locally installed Python 2.7.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/spicmacay/.local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/spicmacay/.local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
>>>
UPDATE: When I run ./configure&& make, I get:
make
running build
running build_ext
building dbm using gdbm
INFO: Can't locate Tcl/Tk libs and/or headers
Python build finished, but the necessary bits to build these modules were not found:
_sqlite3 _tkinter bsddb185
dl imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
running build_scripts
Came to this issue also.. fixed by compiling Python and passing sqlite3 headers/libs during ./configure
Python 2.7.3 _sqlite3 module is not being built after passing headers/libraries
Posted just in case anyone else has this issue in the future and does not have sudo access to a node.
This happened me recently. You need to apt-get install libsqlite3-dev (on debian - sqlite-devel possibly elsewhere) and recompile python.
If you first ./configure sqlite3 with a --prefix option, then make and make install it and then use the same --prefix when compiling Python, the Python installation will be able to magically find and use the sqlite3 you just installed.
cd sqlite-autoconf-3080100
./configure --prefix=/home/xdanek7/appscale/local
make
make install
cd ../Python-2.7.6
./configure --prefix=/home/xdanek7/appscale/local
make
make install
Try adding sudo before the command apt-get install libsqlite3-dev to get rid of "NO root access"
i.e on terminal, write:
sudo apt-get install libsqlite3-dev
I'm trying to install gevent on a fresh EC2 CentOS 5.3 64-bit system.
Since the libevent version available in yum was too old for another package (beanstalkd) I compiled/installed libevent-1.4.13-stable manually using the following command:
./configure --prefix=/usr && make && make install
This is the output from installing gevent:
[gevent-0.12.2]# python setup.py build --libevent /usr/lib
Using libevent 1.4.13-stable: libevent.so
running build
running build_py
running build_ext
Linking /usr/src/gevent-0.12.2/build/lib.linux-x86_64-2.6/gevent/core.so to
/usr/src/gevent-0.12.2/gevent/core.so
[gevent-0.12.2]# cd /path/to/my/project
[project]# python myscript.py
Traceback (most recent call last):
File "myscript.py", line 9, in <module>
from gevent.wsgi import WSGIServer as GeventServer
File "/usr/lib/python2.6/site-packages/gevent/__init__.py", line 32, in <module>
from gevent.core import reinit
ImportError: /usr/lib/python2.6/site-packages/gevent/core.so: undefined symbol: evhttp_accept_socket
I've followed exactly the same steps on a local VirtualBox instance (32-bit) and I'm not seeing any errors.
How would I fix this?
Easiest fix was to clone the git repository, switch to the wip-all branch, and run python setup.py build_libevent build install which grabs & builds libevent statically against gevent:
# git clone http://github.com/schmir/gevent.git
# cd gevent
# git branch -a
* upstream
origin/HEAD
origin/close-socket-cancel-event
origin/pywsgi-without-basehttpserver
origin/upstream
origin/wip-all
origin/wip-setup-config
# git checkout origin/wip-all
# python setup.py build_libevent build install
More information here.