0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

じぶんpython環境メモ

Last updated at Posted at 2021-01-01
katayamashunyuunoMacBook-Pro:~ katayamashunsuke$ which python
/Users/katayamashunsuke/.pyenv/shims/python
#pyenvのpythonを使っている

katayamashunyuunoMacBook-Pro:~ katayamashunsuke$ which pip
/Users/katayamashunsuke/.pyenv/shims/pip
#pipもpyenv由来

katayamashunyuunoMacBook-Pro:~ katayamashunsuke$ which conda
katayamashunyuunoMacBook-Pro:~ katayamashunsuke$ which anaconda
#conda anacondaは入ってない

katayamashunyuunoMacBook-Pro:~ katayamashunsuke$ pyenv versions
  system
  3.6.5
* 3.7.4 (set by /Users/katayamashunsuke/.pyenv/version)
  3.7.7
  3.8.2
  anaconda3-5.3.1
#anacondaでjupyter notebookを使いたい時はpyenvからlocalで使う
#使い方
#適用ディレクトリに移動して
pyenv local anaconda3-5.2.0
jupyter-notebook

pipとcondaをconflictさせずにどっちも使うことができる。
#pipenvについて
ここを見ろ
https://rinatz.github.io/python-book/ch04-05-pipenv/

cvxpy周りの環境について

作成したconda環境内でしっかりjupyterしましょうという話
ここではcondaで仮想環境を作っている

環境の作り方
$ x64..x86_64環境への切り替え
$ conda create --name cvxpy
$ echo ". /Users/katayamashunsuke/.pyenv/versions/anaconda3-5.3.1/etc/profile.d/conda.sh" >> ~/.zshrc
$ conda activate cvxpy
$ conda install -c conda-forge cvxpy
$ conda install jupyter
$ jupyter notebook

これは今はやらなくてもなんか上手く行ってる。上手く行かない時はみてみる

cvxpy環境への入り方
$ x64
$ conda activate cvxpy
$ jupyter-notebook

M1周りの設定について

#アーキテクチャをx86_64に変更
x64
#アーキテクチャをarm64に変更
a64
#アーキテクチャ確認
uname -m

下記はモジュールのimport元について。anaconda環境においてはpipからのインストールは行われていない。

#anaconda3-5.3.1
>>> sys.path
['', 
'/Users/katayamashunsuke/.pyenv/versions/anaconda3-5.3.1/lib/python37.zip', 
'/Users/katayamashunsuke/.pyenv/versions/anaconda3-5.3.1/lib/python3.7', 
'/Users/katayamashunsuke/.pyenv/versions/anaconda3-5.3.1/lib/python3.7/lib-dynload', 
'/Users/katayamashunsuke/.pyenv/versions/anaconda3-5.3.1/lib/python3.7/site-packages', 
'/Users/katayamashunsuke/.pyenv/versions/anaconda3-5.3.1/lib/python3.7/site-packages/aeosa']

#3.9.2
>>> sys.path
['', 
'/Users/katayamashunsuke/.pyenv/versions/3.9.2/lib/python39.zip', 
'/Users/katayamashunsuke/.pyenv/versions/3.9.2/lib/python3.9', 
'/Users/katayamashunsuke/.pyenv/versions/3.9.2/lib/python3.9/lib-dynload', 
'/Users/katayamashunsuke/.pyenv/versions/3.9.2/lib/python3.9/site-packages']

#importしたモジュールのverison確認
>>> import matplotlib
>>> print(matplotlib.__version__)
3.4.2

#pyenvで何故かglobalが反映されない時に見る場所
下のページの主にpathの部分
https://github.com/pyenv/pyenv#basic-github-checkout

#pythonでモジュールのimport元を確認する

import pandas as pd
print(pd.__version__)

#pythonでimport環境を確認する

mport sys
import pprint
pprint.pprint(sys.path)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?