| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
1,566 バイト追加 、 2024年9月17日 (火) 08:14
*[[CentOS6にPython2.7をインストール]]
*[[Django インストール]]
=====Macにインストール=====
----
*Homebrewのインストール
https://brew.sh/
<pre>
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
</pre>
*pyenv のインストール
<pre>
brew install pyenv
</pre>
*~/.bash_profileに追記
<pre>
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
</pre>
 
*pythonバージョン確認
<pre>
$ pyenv install --list | egrep '[ ]+3.*'
</pre>
*pythonインストール
<pre>
$ pyenv install 3.12.6
</pre>
*以下のエラーの場合
<pre>
The Python lzma extension was not compiled. Missing the lzma lib?
</pre>
xzライブラリのインストール
<pre>
brew install xz
</pre>
再インストール
<pre>
$ pyenv uninstall 3.12.6
pyenv: remove /Users/piroto/.pyenv/versions/3.12.6? [y|N] y
pyenv: 3.12.6 uninstalled
$ pyenv install 3.12.6
</pre>
*使用バージョンの設定
<pre>
pyenv versions
$ pyenv global 3.12.6
</pre>
====[[言語まとめ Python|言語まとめ]]====
==仮想環境==
===VirtualEnvを利用して[[Python]]の仮想環境を作成===
----
 
===[[Python]] 3以降同梱されている===
----
*https://docs.python.jp/3/library/venv.html
python3 -m venv ./envs/env01
 
./env/env01/Scrits/activate
 
 
 
====エラー====
----
*Ubuntu
<pre>
$ python3 -m venv ./env/env_ml
Failing command: ['/home/piroto/workspaces/python/env/env_ml/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
</pre>
*対処
<pre>
 
</pre>
 
===[[Visual Studio Code]]===
----
*[[Visual Studio Code]]の場合、Ctrl+Shift+Pで、Python:Select Interpreter を選択することで実行する仮想環境を選択できる。選択するとIDEの左下に表示される。
*settings.json に以下を追加
<pre>
{
"python.pythonPath": "{virtual envで作成したパス}/bin/python3"
}
</pre>
===それ以前===
====[[Python CSVファイル]]====
===書式===
 
====文字列展開====
*https://qiita.com/takechiyosw/items/27942ab481370fea604f
*f-string
v = "hoge"
print(f"content:{v}")
 
 
====文字列を16進数に変換====
print 'hoge'.encode('hex')
&gt;&gt;&gt; '.'.join([str(int(x,2)) for x in "10101100.00011111.00010000.00100000".split(".")])
'172.31.16.32'
 
===ログ===
*[[Python 任意のファイルにログを出力する]]
*[[Python ユニコードエスケープをデコード]]
*[[Python 対話シェルへユニコードを文字として表示する]]
 
[[category:プログラミング言語]]

案内メニュー