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.

【TIPS】cloud9でpythonのコマンドを打つとエラーが出たのでバージョンを上げる

Last updated at Posted at 2022-12-29

やりたいこと

cloud9でテスト環境を作成した際にpythonのコマンドを確認すると以下のようなエラーが出た。pythonのバージョンが古そうな感じがしているのでアップグレードをして対応したい。

hogehoge:~/environment/python $ python -v
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook

~~~~長いので省略

手順

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ ~/.pyenv/bin/pyenv --version

## ~/.bash_profileに以下を追加し、pyenvのパス設定と設定を行う

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init --path)"
fi

$ source ~/.bash_profile
$ pyenv --version

## 今回は3.8.10をインストールします。

$ pyenv install -l | grep 3.8.
$ pyenv install 3.8.10

$ pyenv versions
$ pyenv global 3.8.10

$ python -m pip install --upgrade pip

$ python -V
$ python -m pip -V

とりあえず更新されるのを待つまではこの手順で耐えるしかないか・・・

0
0
1

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?