This is the environment construction procedure when you want to create a Python + OpenCV development environment on AWS Cloud9. In particular, the various installation parts were troublesome, so I will summarize them. (I don't know if it's the best method, I'm sorry.)
I created it with ʻEC2 instance type: t3.small`, but please choose any instance type and create it.
The default volume for t3.small is 10GiB.
If this is the case, the capacity will be insufficient at the stage of various installations, so expand the capacity. (If there is not enough space, No space left on device
will be displayed during installation).
Please refer to the following article for the extension procedure.
https://qiita.com/ktrkmk/items/8cf1e100da2e717f3be2
I once expanded to 30 GiB.
Install with the following command.
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
It is said that there is no path, so execute the following commands in order to deal with it.
$ test -d ~/.linuxbrew && PATH="$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH"
$ test -d /home/linuxbrew/.linuxbrew && PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
$ test -r ~/.bash_profile && echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.bash_profile
$ echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.profile
Check if it can be executed. If the version is displayed, it's OK.
$ brew -v
Homebrew 2.2.11
Homebrew/linuxbrew-core (git revision 9d9624; last commit 2020-04-05)
Install with the following command.
$ brew install pyenv
Check if it can be executed. If the version is displayed, it's OK.
$ pyenv -v
pyenv 1.2.18
Specify the version you want to install and execute. (This time it is 3.8.1.)
$ pyenv install 3.8.1
Check if it is installed.
$ pyenv versions
* system (set by /home/ec2-user/.pyenv/version)
3.8.1
3.8.1
is displayed, but since*
is attached to system
, change this.
$ pyenv global 3.8.1
confirm one more time.
$ pyenv versions
system (set by /home/ec2-user/.pyenv/version)
* 3.8.1
It is OK if *
is moved to 3.8.1
.
Check the Python version again here.
$ python --version
Python 3.6.10
You'll probably see the original Python version, so edit bash_profile
to be able to run the Python version of pyenv.
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
$ exec $SHELL -l
Check the Python version, and if it is reflected, it's OK.
$ python --version
Python 3.8.1
Initially
$ brew install opencv
I tried to install it with this, but it didn't work ...
So I used pip
.
$ pip install opencv-python
To check if it is installed
$ python
>>> import cv2
If no message appears, it's OK. This completes the environment construction.
https://qiita.com/nasuvitz/items/5eec6ab9444cff8e9467 https://prog-8.com/docs/python-env https://www.lifewithpython.com/2018/01/python-checking-version.html https://news.mynavi.jp/article/zeropython-34/ https://qiita.com/makki_maki04/items/f62c5e4e68709d9b3b89 https://dev.classmethod.jp/articles/aws-cloud9-pyenv/
Recommended Posts