Last active
October 30, 2024 17:01
-
-
Save wpupru/deda1cd96ea242d9a790e50cd0c97e9f to your computer and use it in GitHub Desktop.
Install Python 3.7.0 on Centos 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install Python 3.7.0 on CentOS/RHEL 7 | |
1.Requirements: | |
yum install gcc openssl-devel bzip2-devel | |
2.Download Python 3.7: | |
cd /usr/src | |
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz | |
tar xzf Python-3.7.0.tgz | |
3.Install Python 3.7.0: | |
cd Python-3.7.0 | |
./configure --enable-optimizations | |
make altinstall | |
(make altinstall is used to prevent replacing the default python binary file /usr/bin/python) | |
4.Remove downloaded source archive file from your system: | |
rm /usr/src/Python-3.7.0.tgz | |
5.Check Python Version | |
python3.7 -V | |
echo 'alias python3.7="python3"' >> ~/.bashrc | |
********************************************************************** | |
Команды Python: | |
django-admin startproject firstproject // создание нового проекта | |
django-admin -h // посмотреть все команды | |
#Создание нового приложения: | |
python manage.py startapp firstapp | |
I did the above and also
$ ln -s /usr/local/bin/python3.7 /usr/bin/python3.7 $ ln -s /usr/local/bin/pip3.7 /usr/bin/pip3.7
$ python3.7 -V Python 3.7.9
I am now trying to create a virtualenv and get the following:
$ virtualenv -p python3.7 venv Running virtualenv with interpreter /usr/local/bin/python3.7 Using base prefix '/usr/local' /usr/lib/python3.6/site-packages/virtualenv.py:1043: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp New python executable in /opt/petadex/venv/bin/python3.7 Also creating executable in /opt/petadex/venv/bin/python Installing setuptools, pip, wheel... Complete output from command /opt/petadex/venv/bin/python3.7 - setuptools pip wheel: Traceback (most recent call last): File "<stdin>", line 7, in <module> File "/usr/share/python3-wheels/pip-9.0.3-py2.py3-none-any.whl/pip/__init__.py", line 44, in <module> File "/usr/share/python3-wheels/pip-9.0.3-py2.py3-none-any.whl/pip/vcs/mercurial.py", line 9, in <module> File "/usr/share/python3-wheels/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 36, in <module> File "/usr/share/python3-wheels/pip-9.0.3-py2.py3-none-any.whl/pip/utils/glibc.py", line 4, in <module> File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes' ---------------------------------------- ...Installing setuptools, pip, wheel...done. Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/virtualenv.py", line 2333, in <module> main() File "/usr/lib/python3.6/site-packages/virtualenv.py", line 714, in main symlink=options.symlink) File "/usr/lib/python3.6/site-packages/virtualenv.py", line 949, in create_environment download=download, File "/usr/lib/python3.6/site-packages/virtualenv.py", line 905, in install_wheel call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT) File "/usr/lib/python3.6/site-packages/virtualenv.py", line 798, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command /opt/petadex/venv/bin/python3.7 - setuptools pip wheel failed with error code 1
Appreciate any and all help
Had same issue on Centos 7, it can be fixed by install some packages such as libffi-devel. If it does not work maybe try install the following:
yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel
After installing these packages, you have to reinstall the version of python. It went well in my case. Hope it helps
You will need :
sudo yum install libffi-devel
That works perfectly AlmaLinux release 8.5
Here's my one-liner (well, a 3-liner) for installing Python 3.7 on CentOS7
sudo su
yum install -y wget gcc openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel ; cd /usr/src; wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz ; tar xzf Python-3.7.0.tgz ; cd Python-3.7.0 ; ./configure --enable-optimizations ; make altinstall ; rm -rf /usr/bin/python3 ; ln -s /usr/local/bin/python3.7 /usr/bin/python3 ; python3 -V
uname -a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you please help me to resolve this issue. I have posted it on Linux exchange.
https://unix.stackexchange.com/questions/610875/modulenotfounderror-no-module-named-sqlite3
I am using Centos7 with Linux server and getting below issue with Python3.7 version
`[xyz@innolx20122 sd-test]$ python3.7
Python 3.7.0 (default, Sep 3 2020, 09:25:25)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
`