In this article, I quickly created a virtual environment for centos on my PC. The purpose is to install python3.5 in it and play with it.
The method of launching centos using vagrant was still introduced in "here", so please have a look if you are interested.
In order to use vagrant, you need to prepare the following two.
It's 1 minute so far.
Create a suitable directory and put centos7 in it.
$ mkdir test_centos
$ cd test_centos
$ vagrant init CentOS7
$ vagrant up
#Now that you have the environment for centos7, let's go in with ssh and check it.
$ vagrant ssh
Last login: Fri Apr 14 00:32:50 2017 from 10.0.2.2
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
#It looks like it's in
In yum's default repository, python only contains 2.7. Therefore, I will add a repository called ius.
[vagrant@localhost ~]$ sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
[vagrant@localhost ~]$ sudo yum install -y python35u python35u-libs python35u-devel python35u-pip
When I check the version, it's okay ...
[vagrant@localhost ~]$ python -V
Python 2.7.5
Aw. ..
Apparently it seems to be related to bin alias, so it seems good to change it below.
Current status
[vagrant@localhost ~]$ ll /bin/py*
-rwxr-xr-x.1 root root 78 June 17 2014/bin/pydoc
lrwxrwxrwx 1 root root 8 april 14 00:35 /bin/pydoc3 -> pydoc3.4
-rwxr-xr-x 1 root root 78 November 9 17:26 /bin/pydoc3.4
-rwxr-xr-x 1 root root 78 January 17 21:36 /bin/pydoc3.5
lrwxrwxrwx 1 root root 12 april 14 00:38 /bin/python -> /bin/python2
lrwxrwxrwx.1 root root 9 July 16 2015/bin/python2 -> python2.7
-rwxr-xr-x.1 root root 7136 June 17 2014/bin/python2.7
-rwxr-xr-x 2 root root 11312 November 9 17:27 /bin/python3.4
-rwxr-xr-x 2 root root 11312 November 9 17:27 /bin/python3.4m
-rwxr-xr-x 2 root root 11312 January 17 21:37 /bin/python3.5
-rwxr-xr-x 2 root root 11312 January 17 21:37 /bin/python3.5m
-rwxr-xr-x 1 root root 173 January 17 21:36 /bin/python3.5m-config
-rwxr-xr-x 1 root root 3398 January 17 21:34 /bin/python3.5m-x86_64-config
lrwxrwxrwx 1 root root 10 april 14 00:35 /bin/pyvenv -> pyvenv-3.4
-rwxr-xr-x 1 root root 230 November 9 17:26 /bin/pyvenv-3.4
-rwxr-xr-x 1 root root 230 January 17 21:36 /bin/pyvenv-3.5
Summary
command | Destination | さらにそれのDestination |
---|---|---|
python | pythn2 | python2.7 |
It would be nice if python could be directed to python3> python3.5.
##First of all, the direction of python3 is python3.Create an alias to be 5
[vagrant@localhost ~]$ sudo ln -s /bin/python3.5 /bin/python3
##I will erase the existing python alias
[vagrant@localhost ~]$ sudo unlink /bin/python
##python should be directed to python3
[vagrant@localhost ~]$ ln -s /bin/python3 /bin/python
[vagrant@localhost ~]$ python -V
Python 3.5.3
Sounds good.
It seems good to finally pip together.
[vagrant@localhost ~]$ sudo ln -s /bin/pip3.5 /bin/pip
In just 3 minutes so far, I was able to get centos7 and python3.5 in my environment. My purpose is scraping, but it's a really easy and convenient world.
Recommended Posts