Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes

Background

Trying to use vaex, is it a bug in the OS default Python 2.7.5? Cannot be used by I was lightly addicted to installing Python 2.7.17 and trying to continue the project, so make a note.

environment

CentOS 7.5.1804 Python2.7.17 Poetry 1.0.5 tcsh

Installation

I tried other installation methods such as pyenv, but decided to use sclo python, which seems to be the easiest to build an environment on another machine.

sudo yum -y install centos-release-scl-rh
sudo yum -y install python27

Normally, / opt / rh / python27 / enable should be installed here, but there are times when it is not done for some reason. In that case, either handwrite it or install python36 etc. and copy and modify enable. Since enable is written in bash, rewrite it in tcsh.

vim /opt/rh/python27/enable
#!/usr/bin/env tcsh

if ($?PATH) then
  setenv PATH /opt/rh/python27/root/usr/bin:${PATH}
else
  setenv PATH /opt/rh/python27/root/usr/bin
endif
if ($?LD_LIBRARY_PATH) then
  setenv LD_LIBRARY_PATH /opt/rh/python27/root/usr/lib64:${LD_LIBRARY_PATH}
else
  setenv LD_LIBRARY_PATH /opt/rh/python27/root/usr/lib64
endif

if ($?MANPATH) then
  setenv MANPATH /opt/rh/python27/root/usr/share/man:${MANPATH}
else
  setenv MANPATH /opt/rh/python27/root/usr/share/man
endif

if ($?PKG_CONFIG_PATH) then
  setenv PKG_CONFIG_PATH /opt/rh/python27/root/usr/lib64/pkgconfig:${PKG_CONFIG_PATH}
else
  setenv PKG_CONFIG_PATH /opt/rh/python27/root/usr/lib64/pkgconfig
endif

if ($?XDG_DATA_DIRS) then
  setenv XDG_DATA_DIRS /opt/rh/python27/root/usr/share:${XDG_DATA_DIRS}
else
  setenv XDG_DATA_DIRS /opt/rh/python27/root/usr/share
endif

activation

Since it is tcsh, scl enable python27 tcsh cannot be used like other shells, so enable is directly sourced and enabled.

$ python -V
Python 2.7.5

$ source /opt/rh/python27/enable
$ python -V
Python 2.7.17

OK if the version has changed properly.

Poetry environment creation

p ** in the shell that sourced enable ** poetry init If you have already created virtualenv with OS Python, delete the environment once and poetry install This will create an environment in SCLO Python.

Development environment

There is no problem with the statement used from the terminal so far, but when I tried to use Python in the created environment from PyCharm, an error occurred and it did not work. (Error log disappeared)

The cause was that the environment variable set by enable was not set from PyCharm. It's not very pretty, but I solved it by making python2.7 a shell script and source enable when executing python.

cd `poetry env info --path`/bin
mv python2.7 python2.7_original

vim python2.7

python2.7


#!/usr/bin/env tcsh

source /opt/rh/python27/enable
`dirname $0`/python2.7_original $*

Recommended Posts

Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
Environment construction of python2 & 3 (OSX)
Environment construction of python and opencv
Environment construction of python3.8 on mac
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
pytorch @ python3.8 environment construction with pipenv
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Let's get along with Python # 0 (Environment construction)
Collecting information from Twitter with Python (Environment construction)
Prepare the execution environment of Python3 with Docker
Unification of Python environment
python windows environment construction
homebrew python environment construction
Python development environment construction
Use multiple versions of python environment with pyenv
Installation of Python3 and Flask [Environment construction summary]
Python environment with docker-compose
python2.7 development environment construction
First python ① Environment construction with pythonbrew & Hello World !!
Mac environment construction Python
From Python environment construction to virtual environment construction with anaconda
Virtual environment with Python 3.6
Automatic posting of web design gary site with python + selenium (1) Environment construction
Python environment construction @ Win7
Recommendation of building a portable Python environment with conda
[Python] OpenCV environment construction with Docker (cv2.imshow () also works)
Data analysis environment construction with Python (IPython notebook + Pandas)
Web application made with Python3.4 + Django (Part.1 Environment construction)
QGIS3 Python plugin development environment construction with VSCode (macOS)
Python + Anaconda + Pycharm environment construction
Install Python environment with Anaconda
Manage python environment with virtualenv
Python environment construction (Windows10 + Emacs)
[Memo] Construction of cygwin environment
Build python3 environment with ubuntu 16.04
ML environment construction with Miniconda
Python environment construction For Mac
Prepare python3 environment with Docker
Build python environment with direnv
Python3 environment construction (for beginners)
Python environment construction and TensorFlow
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
Unify the environment of the Python development team starting with Poetry
[LDAP environment construction: 7] Add / search / change / delete users with Python
Construction of Python local development environment Part 2 (pyenv-virtualenv, pip usage)
Notes on handling large amounts of data with python + pandas
Automatic scraping of reCAPTCHA site every day (1/7: python environment construction)
Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Build python virtual environment with virtualenv
Setup modern Python environment with Homebrew
Start of self-made OS 1. Environment construction
Python + Unity Reinforcement learning environment construction
ruby environment construction with aws EC2