If you are installing the python3 on centos7 than it comes by default shipped with python 2.7.5 which is required by the core os of the centos. Now if you try to install through yum than you can't directly install the python3 instead you would require to install the software collections first.
Software collections is an community project which allows you to build, install and use the multiple version of software on same system without affecting default system packages. It will enable the multiple version of the programming languages which are not available in the core repositories.
To install scl run the following command
# yum install centos-release-scl
To install the python3 run
# yum install rh-python36
You will also need to install the 'Development tools' which are required for building python modules
# yum groupinstall 'Development Tools'
Python virtual environments allows you to install the python modules in isolated location for a specific project, rather than being installed globally. This way it does not affect other python projects.
You can use venv to create the virtual environment in python
Create a new project folder where all project related files and binaries will reside
#mkdir project
# cd project
Next you have to enable the python36 with the scl first before you can use it do
#scl enable rh-python36 bash
You can create the virtual environment
python -m venv my_project_venv
Execute the following command to enable the virtual environment
source my_project_venv/bin/activate
You should get a cursor as below now
$ (my_project_venv) user@host:~/my_new_project$
The prefix indicates that the Python virtual environment my_project_venv is currently active
Now your virtual environment is ready to use.
Software collections is an community project which allows you to build, install and use the multiple version of software on same system without affecting default system packages. It will enable the multiple version of the programming languages which are not available in the core repositories.
To install scl run the following command
# yum install centos-release-scl
To install the python3 run
# yum install rh-python36
You will also need to install the 'Development tools' which are required for building python modules
# yum groupinstall 'Development Tools'
Python virtual environments allows you to install the python modules in isolated location for a specific project, rather than being installed globally. This way it does not affect other python projects.
You can use venv to create the virtual environment in python
Create a new project folder where all project related files and binaries will reside
#mkdir project
# cd project
Next you have to enable the python36 with the scl first before you can use it do
#scl enable rh-python36 bash
You can create the virtual environment
python -m venv my_project_venv
Execute the following command to enable the virtual environment
source my_project_venv/bin/activate
You should get a cursor as below now
$ (my_project_venv) user@host:~/my_new_project$
The prefix indicates that the Python virtual environment my_project_venv is currently active
Now your virtual environment is ready to use.
0 comments:
Post a Comment