Rebuild Python3.5 to Fix pip install uwsgi Error on Ubuntu18

2018-09-27 12:26 (6 years ago) ytyng

After updating to Ubuntu 18, the default Python version on my machine became Python 3.6, but I needed to perform some validation with Python 3.5.

python3.5 -m venv venv35

First, I created a virtual environment with the command above.

. venv35/bin/activate
pip install uwsgi

However, when I tried to install uWSGI, I encountered the following errors:

    /usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/python3.5/config-3.5m/libpython3.5m.a(mystrtoul.o): relocation R_X86_64_32S against symbol `_Py_ctype_table' can not be used when making a PIE object. Please recompile with -fPIC.
    /usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/python3.5/config-3.5m/libpython3.5m.a(structmember.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object. Please recompile with -fPIC.
    /usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/python3.5/config-3.5m/libpython3.5m.a(parser.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object. Please recompile with -fPIC.
    /usr/bin/x86_64-linux-gnu-ld: Final link failed: No section matching the output
    collect2: error: ld returned 1 exit status
    *** error linking uWSGI ***

Due to these errors, the linking process failed.

Therefore, I decided to rebuild Python 3.5 from source.

curl -O https://www.python.org/ftp/python/3.5.6/Python-3.5.6rc1.tgz
tar -xzvf Python-3.5.6rc1.tgz
cd Python-3.5.6rc1/
./configure --prefix=$HOME/.local --enable-optimizations
make -s -j2
make install

Using this newly built Python, I created another virtual environment:

~/.local/bin/python3.5 -m venv venv356
. venv356/bin/activate
pip install uwsgi

This time, the installation was successful.

Reference

Installing Python from source on Ubuntu

https://qiita.com/yniji/items/8e392103a6f2a4152606

Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011