1
1

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 5 years have passed since last update.

Amazon LinuxにMkDocsの環境を作ってみる(未遂)

Last updated at Posted at 2016-04-08

ちょっと知ったMkDocsで、運用手順書なんかを管理できたら良いな、と思い、簡単に環境構築しようとしたのが始まり。

注意!!
この記事は結果的に失敗したので、完成はこちらの記事参照していただき、以下の失敗談はかっとばしてください。。。
(これは自分の備忘録的なものです)

前提

  • AWSにAmazonLinuxのEC2を準備しておく
  • yum updateを行い、最新状態にしておく
  • 実行ユーザはデフォルトのec2-userとする
  • Python環境はAmazon Linuxのデフォルト(Python 2.7.10)を用いる ※2016/4/6時点

環境準備

MkDocsを使ってドキュメントのサイトの自動でこしらえるを参考に実施しました。

pipのインストール

Pythonのパッケージ管理pipをインストールする。
公式サイトの手順に従い、以下を実行。

$ sudo wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

Collecting pip
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 49kB/s 
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 290kB/s 
Installing collected packages: pip, wheel
  Found existing installation: pip 6.1.1
    Uninstalling pip-6.1.1:
      Successfully uninstalled pip-6.1.1
Successfully installed pip-8.1.1 wheel-0.29.0

mkdocsのインストール

$ sudo pip install mkdocs

~~省略~~

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 344, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 315, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/markdown'

pipが最新化していなかったのを思い出し、以下を実行。

$ pip install -U pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages

多分成功。
ちなみに、sudoをつけたらエラーが出た・・・この辺、疎いので調べてもいません。。。

$ sudo pip install -U pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 616, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 629, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 807, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==6.1.1

ん?sudo要らない?
と、思い立ち、sudo無しで実行してみる。

$pip install mkdocs
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/markdown'

となり、やっぱり同じエラー。。。
エラー箇所を見ると、markdownが無いっぽいので、pipでインストールしてみる。

$ pip install markdown
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/markdown'

となり、同じエラー。。。
ここで気がつく。
何かパスが違くね?

$ ls -l /usr/local/lib/python2.7/site-packages
total 20
drwxr-xr-x 10 root root 4096 Apr  6 13:11 pip
drwxr-xr-x  2 root root 4096 Apr  6 13:11 pip-8.1.1.dist-info
-rw-r--r--  1 root root  119 Dec  9 03:25 README
drwxr-xr-x  5 root root 4096 Apr  6 13:11 wheel
drwxr-xr-x  2 root root 4096 Apr  6 13:11 wheel-0.29.0.dist-info
$ ls -l /usr/local/lib64/python2.7/site-packages/
total 4
-rw-r--r-- 1 root root 119 Dec  9 03:25 README

どうもsudoによるpathがおかしいように思う。
一度pipを強制再インストールする。

$ sudo python get-pip.py --force-reinstall
Collecting pip
  Using cached pip-8.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
Successfully installed pip-8.1.1
$ pip install mkdocs

~~省略~~

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 344, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 315, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/markdown'

やっぱりダメ・・・心が折れたので、一時中断。

まとめ

  • 結局環境構築できなかった
  • Amazon Linuxによる権限回りが良く分かっていない
  • sudoの有無で参照先が異なるような動き有り

悔しいので、再チャレンジします!!

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?