LoginSignup
0
0

More than 1 year has passed since last update.

if you encounter 'parser ModuleNotFoundError' when running NFStest on Jammy

Last updated at Posted at 2023-01-19

問題

Ubuntu 22.04NFStest-3.0を動作させようとすると以下のエラーメッセージで実行できず。

vagrant@ubuntu-jammy:~/NFStest-3.0/test$ ./nfstest_posix -h
Traceback (most recent call last): File
"/home/vagrant/NFStest-3.0/test/./nfstest_posix", line 27, in <module> from nfstest.test_util import TestUtil File
"/home/vagrant/NFStest-3.0/nfstest/test_util.py", line 60, in <module> from nfstest.nfs_util import NFSUtil File
"/home/vagrant/NFStest-3.0/nfstest/nfs_util.py", line 34, in <module> from nfstest.host import Host File
"/home/vagrant/NFStest-3.0/nfstest/host.py", line 33, in <module> from packet.pktt import Pktt File
"/home/vagrant/NFStest-3.0/packet/pktt.py", line 49, in <module> import parser ModuleNotFoundError: No module named 'parser'
vagrant@ubuntu-jammy:~/NFStest-3.0/test$

原因は、Python 3.10以降で、parseモジュールが削除されたため(参考:Whatever happened to package 'parser' in Python 3.10?)。

対処

NFStest-3.0の実行時のインタプリタとして、python 3.9を使用する。
具体的には、pyenvを使用して対処する。pyenvは、実行環境のpythonのバージョンをコントロールすることができる。詳細は、pyenvを参照されたい。
以下に、Ubunt 22.04でのログインshellがbashであるユーザへのpython 3.9を導入する手順を示す。

Ubuntu 22.04へのpyenvのインストール

pyenvのREADME.mdの記載内容をUbuntu 22.04向けにサマライズする。

  1. pyenvのインストール

     git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    
  2. shell環境の準備

    1. .bashrcの編集

       echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
       echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
       echo 'eval "$(pyenv init -)"' >> ~/.bashrc
      
    2. .profileの編集

       echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
       echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
       echo 'eval "$(pyenv init -)"' >> ~/.profile
      
    3. 実行環境への反映

       exec "$SHELL"
      
  3. pythonのビルド環境の準備

     sudo apt update -y; sudo apt install -y build-essential libssl-dev zlib1g-dev \
     libbz2-dev libreadline-dev libsqlite3-dev curl llvm \
     libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
    

Ubuntu 22.04へのpython 3.9のインストールと環境設定

  1. python 3.9のインストール

    以下のコマンドで、3.9の最新版をインストール。

     pytenv insatll $(pyenv install -l | egrep "^\s+3\.9" | tail -1)
    
  2. python 3.9の有効化

     pyenv global $(pyenv versions | sed -nEe 's/.*(3\.9\.[[:digit:]]+).*/\1/p' | sort -V | tail -1)
    
  3. pythonのバージョン確認

     python --version
    

Ubuntu 22.04でのNFStest-3.0の実行

  1. NFStest-3.0のダウンロードと展開

     wget http://www.linux-nfs.org/~mora/nfstest/releases/NFStest-3.0.tar.gz
     tar -xzvf NFStest-3.0.tar.gz
    
  2. NFStest-3.0の実行

     cd NFStest-3.0
     export PYTHONPATH=$PWD
     cd test
     sudo mkdir -p /mnt/t
     ./nfstest_posix -s *server* -e *share* 
    
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