Python environment for projects

As an experience, record the process of Python environment maintenance on CentOS.

Python body

For stability, use the latest version upgrade as much as possible.

At the moment, Python 3.9 is out, but I think 3.8.6 is more stable, so I will use it.

Since the version of the package managed by Linux itself is low, I think that Conda and others are troublesome, so I use the method of compiling from the source code.

First, install various tools for development. If you omit it, you may have problems with Python and pip.

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel

Next, get the Python source code. Find it on the Python site (https://www.python.org/downloads/) and download tgz.

Then run as root.

tar -zxvf Python-3.8.6.tgz  
cd Python-3.8.6
./configure prefix=/usr/local/python3
make && make install

ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3.8
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3.8

Finally, / usr / bin / python3 and / usr / bin / pip3 link to the previous link file. If you already have an older version, you have no choice but to delete it and recreate it.

The unique operating environment of the project

Recent versions like Python 3.8.6 have a part called venv, which I think is good enough.

/usr/bin/python3 -m venv venv

The operation is as follows.

source venv/bin/activate || exit 1
python3 [PATH_OF.PY]
deactivate

About the requested package

Requirements.txt is required for projects that use third-party packages.

source venv/bin/activate || exit 1

#If you use a mirror, accompany it:-i "mirror_url"
pip3 install -r requirements.txt || exit 2

deactivate

Recommended Posts

Python environment for projects
Python environment construction For Mac
Python3 environment construction (for beginners)
[For organizing] Python development environment
Python development environment options for May 2020
Python3 TensorFlow for Mac environment construction
2016-10-30 else for Python3> for:
Python environment construction
python environment settings
python windows environment
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Build an environment for Blender built-in Python
Let's create a virtual environment for Python
[Mac] Building a virtual environment for Python
Building a Python development environment for AI development
About Python for loops
Selenium + WebDriver (Chrome) + Python | Building environment for scraping
[Python] Get environment variables
Python basics ② for statement
Unification of Python environment
python windows environment construction
Building an environment for executing Python scripts (for mac)
homebrew python environment construction
Building an Anaconda environment for Python with pyenv
Python development environment construction
python virtual environment Pipenv
python textbook for beginners
Refactoring tools for Python
Image Processing with Python Environment Setup for Windows
About Python development environment
virtual environment in python
python for android Toolchain
Python environment with docker-compose
Commands for creating a python3 environment with virtualenv
python2.7 development environment construction
Procedure for creating a Python quarantine environment (venv environment)
Development environment in Python
A memo for creating a python environment by a beginner
OpenCV for Python beginners
Virtual environment with Python 3.6
Python environment construction @ Win7
Install Python (for Windows)
[Python] for statement error
Building a Python environment for pyenv, pyenv-virtualenv, Anaconda (Miniconda)
Write about building a Python environment for writing Qiita Qiita
Building a Docker working environment for R and Python
Python 3.4 Create Windows7-64bit environment (for financial time series analysis)
Build a python environment for each directory with pyenv-virtualenv
Summary of python environment settings for myself [mac] [ubuntu]
Use Python installed with pyenv for PL / Python execution environment
Procedure for building a CDK environment on Windows (Python)
Building a Python environment for programming beginners (Mac OS)
Use AWS SDK for Python (boto) under Proxy environment
Python + Anaconda + Pycharm environment construction
Python memo (for myself): Array
About Fabric's support for Python 3
Python list, for statement, dictionary
Python for Data Analysis Chapter 4