This is a memo for myself, but for your reference.
Install "Homebrew" ↓ Install "pyenv" using "Homebrew" ↓ Install "Python" using "pyenv"
Official Homebrew documentation: https://brew.sh/index_ja
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You will be asked to press the return / enter
key on the way, so press it according to the instructions.
You will also be asked to enter the PW when logging in to your PC on the way. Enter the password according to the instructions (however, the entered contents are not displayed on the screen), and press the return / enter
key.
After the installation is complete, check the version with the following command.
$ brew -v
Homebrew 2.2.2
Homebrew/homebrew-core (git revision d7286b; last commit 2020-01-01)
Install pyenv (a tool for building and managing multiple versions of Python environment in the same terminal) using Homebrew. pyenv's GitHub repository: https://github.com/pyenv
$ brew install pyenv
After the installation is complete, check the version with the following command.
$ pyenv -v
pyenv 1.2.13
pyenv settings: Added setting code to .bash_profile
.
Execute the following command line by line (it looks like nothing is happening, but that's OK).
$ 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
Install Python using pyenv.
First, execute the following command to check the version of Python that can be installed with pyenv.
$ pyenv install --list
#Python version that can install the execution result without the first alphabet
2.1.3
2.2.3
2.3.7
・ ・ ・
3.6.5
3.6.6
3.6.7
・ ・ ・
Of these, I installed the relatively new Python 3.6.5.
$ pyenv install 3.6.5
After the installation is complete, check the version of Python installed with the following command.
$ pyenv versions
system
* 3.6.5 (set by /Users/hoge/.pyenv/version)
Execute the following command to change the setting to use the version of Python installed above (otherwise this will continue to use the version of Python that is installed by default on your Mac).
$ pyenv global 3.6.5
Execute the following command to check the version of Python you are using.
$ Python --version
Python 3.6.5
Select Release version = Python 3.6.5
from the following site, download it, and install it according to the instructions.
Python 3.6.5 download page (official): https://www.python.org/downloads/release/python-365/
It seems that any file to download is for Windows, but unless you are particular about it, select Windows x86-64 executable installer
.
When you open the downloaded file, there is a checkbox at the bottom of the screen that says ʻAdd Python 3.6 to PATH. Check this and click ʻInstall Now
.
After the installation is complete, execute the following command at the command prompt (so-called black screen) to check the version.
$ Python --version
Python 3.6.5
If the message "'python' is not recognized ..." is displayed, you may have forgotten to check ʻAdd Python 3.6 to PATH when installing Python. In this case, reopen the first downloaded file, click ʻUninstall
to delete it, and then install it again.
How to use the command prompt from Visual Studio Code
Terminal> Integrated> Automation Shell: Added the following line to
settings.json of Windows
.
settings.json
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe"
}
$ pip install numpy===1.15.0
$ pip install scipy===1.1.0
$ pip install pandas===0.23.3
$ pip install scikit-learn===0.19.2
$ pip install mecab-python3===0.996.2
$ pip install ipykernel
$ pip install mecab-python-windows
$ pip install neologdn===0.3.2
$ git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git
$ cd mecab-ipadic-neologd
$ ./bin/install-mecab-ipadic-neologd -n -a
[install-mecab-ipadic-NEologd] : Start..
[install-mecab-ipadic-NEologd] : Check the existance of libraries
・ ・ ・
[test-mecab-ipadic-NEologd] : Please check difference between default system dictionary and mecab-ipadic-NEologd
default system dictionary | mecab-ipadic-NEologd
Shiro Sano|Shiro Sano
Police academy|Police academy
Mizore|Sleet
Around|Colon
Tarako|Tarakochi
Ichijodani Castle|Ichijodani Castle
Radirer!|Rajira
Kento Hayashi|Kento Hayashi
Matsuko meeting|Matsuko meeting
Ad street|Ad street
[test-mecab-ipadic-NEologd] : Finish..
[install-mecab-ipadic-NEologd] : Please check the list of differences in the upper part.
[install-mecab-ipadic-NEologd] : Do you want to install mecab-ipadic-NEologd? Type yes or no.
yes #Here "Enter yes"
[install-mecab-ipadic-NEologd] : OK. Let's install mecab-ipadic-NEologd.
[install-mecab-ipadic-NEologd] : Start..
[install-mecab-ipadic-NEologd] : /usr/local/lib/mecab/dic is current user's directory
・ ・ ・
[install-mecab-ipadic-NEologd] : Install completed.
[install-mecab-ipadic-NEologd] : When you use MeCab, you can set '/usr/local/lib/mecab/dic/mecab-ipadic-neologd' as a value of '-d' option of MeCab.
[install-mecab-ipadic-NEologd] : Usage of mecab-ipadic-NEologd is here.
Usage:
$ mecab -d /usr/local/lib/mecab/dic/mecab-ipadic-neologd ...
[install-mecab-ipadic-NEologd] : Finish..
[install-mecab-ipadic-NEologd] : Finish..
#Installation is complete. Specify NEologd as the dictionary used by mecab with the following command
$ mecab -d /usr/local/lib/mecab/dic/mecab-ipadic-neologd
In recent years, research on natural language processing has been active.
Nouns in recent years,Adverbs possible,*,*,*,*,recent years,Kinnen,Kinnen
Is a particle,Particle,*,*,*,*,Is,C,Wow
Natural language processing nouns,Proper noun,General,*,*,*,Natural language processing,Shizengen Goshori,Shizengen Goshori
Particles,Attributive,*,*,*,*,of,No,No
Research nouns,Change connection,*,*,*,*,the study,Kenkyu,Kenkyu
Is a particle,Case particles,General,*,*,*,But,Moth,Moth
Popular nouns,Adjectival noun stem,*,*,*,*,Thriving,Sakan,Sakan
Auxiliary verb,*,*,*,Special Death,Uninflected word,is,death,death
EOS
#The default IPAdic is divided into three words, "natural", "language", and "processing", but NEologd processes in one word.
#When using from Python code, MeCab.Tagger()To the argument of'-d /usr/local/lib/mecab/dic/mecab-ipadic-neologd'Is specified.
$ pip install tensorflow===1.14.0
$ pip install Keras===2.1.6
$ pip install gensim===3.5.0
$ pip install hyperopt===0.1.1
$ pip install matplotlib===3.1.2
Check the installed library and its version with the following command.
$ pip list
When trying to install each library with the pip command, the following error message may appear.
# pip3 install hoge
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting hoge
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/hoge/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/hoge/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/hoge/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/hoge/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/hoge/
Could not fetch URL https://hoge/hoge/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='hoge', port=hoge): Max retries exceeded with url: /hoge/hoge/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
Could not find a version that satisfies the requirement hoge (from versions: )
No matching distribution found for hoge
This is because openssl is not installed. In this case, if you install openssl as below and then install Python again, it will work (only for Mac, Windows is unconfirmed).
# 1.Install openssl.
$ brew install openssl
# 2.Changed the preferred SSL from LibreSSL to OpenSSL installed above.
$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
# 3.Exit the terminal and restart it. After that, check the version and OK when OpneSSL is displayed.
$ openssl version
OpenSSL 1.1.1d 10 Sep 2019
# 4.Reinstall Python.
$ pyenv install 3.6.5