(Beginner) Notes on using pyenv on Mac

background

I wanted to see the situation graphically rather than doing the popular Tensorflow tutorial, so when I tried to proceed with reference to the following page, I had trouble displaying the image. ..

--Try the TensorFlow tutorial (1) http://www.mwsoft.jp/programming/tensor/tutorial_beginners.html

I reviewed the environment after I could not display the image with pylab. I will leave it as a memorandum.

By the way, one of the reasons why the image could not be displayed was simply because `plt.show ()` was not done at the end.

environment

Mac OS X El Capitan (10.11)

$ pyenv --version
pyenv 20160509

$ pyenv versions
  system
* 2.7.10 (set by /Users/butada/.python-version)
  3.4.4

Arrangement of problems

It is strange that the python you are using is the OS

I noticed that I am using the same Python as the OS, even though I am using pyenv.

$ which python
/usr/local/bin/python

init was not listed in .bash_profile

After rereading the procedure for building pyenv, There was not enough information in .bash_profile.

eval "$(pyenv init -)"   #There was a shortage here
eval "$(pyenv virtualenv-init -)"

The second line was written, but the first line was not. .. This will cause the libraries installed by pip to It was installed on the OS. ..

backend problem

Change the backend from macosx``` to `TkAgg``` as you will have backend problems with system Python. You can find out which file to change by executing the following command.

python -c "import matplotlib;print(matplotlib.matplotlib_fname())"

In my environment it was in the following path.

vi /Users/butada/.pyenv/versions/2.7.10/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc

#backend      : macosx # comment out 2017/1/4
backend      : TkAgg

Operation check

This time pyenv did not work and matplotlib was installed on the OS, so I had to install matplotlib after setting pyenv correctly. The installation explanation of matplotlib is omitted.

Check if the graph can be displayed

I ran the code on the following page to check it. http://qiita.com/saj_kz/items/40dbfbb84dabcd2a9b46

** Note: ** If you re-execute `plt.show ()` every time you close the window I was wondering if a window would appear,

plt.plot(x,y)I had to start over.



## Check if pyenv is working

 It is OK if it is under the home directory instead of ``` / usr / bin``` or `` `/ usr / local / bin``` as shown below.

$ which python /Users/butada/.pyenv/shims/python


## Check if the Python version is switched with pyenv

 Make sure pyenv switches the python version.

$ mkdir tensorflow $ cd tensorflow

$ pyenv local 3.4.4 $ python --version Python 3.4.4

$ pyenv local 2.7.10 $ python --version Python 2.7.10

$ pyenv local system $ python --version Python 2.7.10 #Python installed on the OS is the same version, so it's hard to see the changes. ..


 You can also check the libraries installed in each.

$ pyenv local 3.4.4 $ pip list

$ pyenv local 2.7.10 $ pip list

$ pyenv local system $ sudo pip list #Since it is an OS, it is not required for list, but sudo is required when installing.


 ** Note: **
 There are three ways to switch versions.

- global
- local
- shell

 I'm scared to try global because it was the whole system.
 local is reflected under that directory. It looks like you've created a .python_version file to save your settings.
 The shell seems to be reflected only in the session of that shell.

 Other commands that can be used

- pyenv versions
- pyenv install --list
- pyenv install 3.4.4

```pyenv local system```It seems to revert to the system default python.

# Finally

 I don't know how to start using pyenv! Or, I'll come back here and calm down when I'm confused when using virtualenv at the same time.

# reference

 --What to do when Python does not switch from the System version with pyenv
http://qiita.com/ta_ta_ta_miya/items/e24394c6b0022405a126
 I was saved by the last `` `~ / .bash_profile``` written on this page.

 --Environment construction with pyenv and virtualenv
http://qiita.com/Kodaira_/items/feadfef9add468e3a85b


Recommended Posts

(Beginner) Notes on using pyenv on Mac
Notes on installing Python using PyEnv
Put Anaconda on your Mac using Pyenv
Install pyenv on mac
Notes on using Alembic
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
Notes on installing dlib on mac
Notes on pyenv and Atom
Notes on optimization using Pytorch
Pyenv on Mac OSX Mavericks
Notes on installing pipenv on Mac
Catalina on Mac and pyenv
Build a Python environment on your Mac using pyenv
Minimum memo when using Python on Mac (pyenv edition)
Minimum notes when using Python on Mac (Homebrew edition)
pyenv notes
Introducing Python using pyenv on Ubuntu 20.04
Notes on using MeCab from Python
Notes on using post-receive and post-merge
Notes on using rstrip with python.
Install Python on CentOS using Pyenv
Notes on using matplotlib on the server
Install Python on CentOS using pyenv
Ansible playbook for setting up Python preferences using pyenv on Mac
How to install Theano on Mac OS X 10.10 (using pyenv, anaconda)
Notes for using OpenCV on Windows10 Python 3.8.3.
Install opencv on Mac using Anaconda Navigator
Notes on implementing APNs tests using Pytest
Notes on using OpenCL on Linux on the RX6800
Error, warning when using TensorFlow on Mac
Video processing using Python + OpenCV on Mac
Read FeliCa using Pasori (RC-380S) on Mac
Notes on using code formatter in Python
Python beginner notes
Notes on Flask
pyenv installation notes
python on mac
Notes on installing Python3 and using pip on Windows7
Install Python 3.8.6 on macOS Big Sur using pyenv
Notes on using dict in python [Competition Pro]
Notes for using TensorFlow on Bash on Ubuntu on Windows
Remove old pyenv environment on Mac and update
[Python] Notes on accelerating genetic algorithms using multiprocessing
Install Tensorflow on Mac
Build a Django development environment using pyenv-virtualenv on Mac
Notes on neural networks
Celery notes on Django
Install Ansible on Mac
Install Python 3 on Mac
Notes on installing PycURL
Run OpenMVG on Mac
Build a Python development environment using pyenv on MacOS
Install Python 3.4 on Mac
Installing pyenv on ubuntu 16.04
Install Caffe on Mac
Notes using Python subprocesses
Install mecab on mac
Install Python environment on local PC (pyenv, venv on Mac)
Try deepdream on Mac
Notes on SciPy.linalg functions
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)