Mr.bob error when creating a new addon

I'm attempting to create a new addon using the instructions from the Plone Docs site on a Mac. I've created a new conda environment for Python 3.7, installed mr.bob 0.1.2 and bobtemplates.plone 5.1.1, and run mrbob -O plonetheme.tango bobtemplates:plone_addon, but I get this error:

Traceback (most recent call last):
  File "/Users/leaderone/miniconda3/envs/plone/bin/mrbob", line 8, in <module>
    sys.exit(main())
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/mrbob/cli.py", line 155, in main
    defaults=defaults)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/mrbob/configurator.py", line 138, in __init__
    self.template_dir, self.is_tempdir = parse_template(template)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/mrbob/configurator.py", line 92, in parse_template
    path = resolve_dotted_path(template_name)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/mrbob/configurator.py", line 40, in resolve_dotted_path
    return os.path.join(os.path.dirname(module.__file__), dir_name)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/posixpath.py", line 156, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

When I try creating an addon through plonecli, I get:

Traceback (most recent call last):
  File "/Users/leaderone/miniconda3/envs/plone/bin/mrbob", line 8, in <module>
    sys.exit(main())
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/mrbob/cli.py", line 175, in main
    c.render()
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/mrbob/configurator.py", line 199, in render
    f(self)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/bobtemplates/plone/addon.py", line 141, in post_render
    run_isort(configurator)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/site-packages/bobtemplates/plone/utils.py", line 76, in run_isort
    cwd=root_folder,
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/Users/leaderone/miniconda3/envs/plone/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tox': 'tox'

I also get errors using Python 2. What am I doing wrong?

late response - but just stumbled upon a similar issue:

adding bobtemplates.plone to a buildout like this lead to the same error for me

[mrbob]
recipe = zc.recipe.egg
eggs =
    mr.bob
    bobtemplates.plone
    tox
    isort

tox/isort needed to be installed into my virtualenv and the virtualenv needs to be activated

bin/pip3 install tox
source bin/activate

bin/mrbob -O src/my.package bobtemplates.plone:addon
1 Like

There is also this nice Plone command line client plonecli

Just once:
pip install plonecli

Create a Plone Add-On:
plonecli create addon greenthumb.fancyaddon

Add some more like a behavior if you want:

cd greenthumb.fancyaddon
plonecli add behavior

thanks for mentioning that @ksuess
nevertheless it's using mrbob under the hood and leads to the same error if tox has not been added to the virtualenv and the venv is not activated

$ ../bin/plonecli create addon my.package

RUN: mrbob bobtemplates.plone:addon -O my.package

Welcome to mr.bob interactive mode. Before we generate directory structure, some questions need to be answered.

Answer with a question mark to display help.
Values in square brackets at the end of the questions show the default value if there is no answer.


--> Author's name [...]: 
...

Error on isort-apply: [Errno 2] No such file or directory: 'tox', make sure you have tox and isort installed globally!

hi @frisi, this is not addressed to you, I know, you are a pro!

pythons with pyenv are handsome pets. I would like to bang the drum for pyenv.

pyenv plus pyenv-virtualenv

create an isolated python

pyenv virtualenv 3.8.7 justtest

activate with

pyenv activate justtest

or make this python your global daily python

then like mentioned above

pip install plonecli
plonecli create addon greenthumb.fancyaddon
cd greenthumb.fancyaddon
plonecli add behavior

From https://github.com/plone/plonecli/blob/master/setup.py:

extras_require={
    "test": test_requirements,
    "dev": ["tox", "zest.releaser[recommended]"],
},

seems that tox is installed only with the dev profile.

Did you install tox an isort globally? Not with pip install but globally in your system!

Here the steps to create a new addon with mr.bob on debian linux. On Mac OSX use brew instead of apt-get. Please read following information from Tox' documentation

You can also find tox packaged for many Linux distributions and Homebrew for macOs - usually under the name of python-tox or simply tox. Be aware though that there also other projects under the same name (most prominently a secure chat client with no affiliation to this project), so make sure you install the correct package.

Install tox an isort globally:

sudo apt-get install -y tox isort

change to your src directory, activate your virtualenv and install tox an isort in your virtualenv:

cd /path/to/zeocluster/src
source ../bin/activate
# sudo ../bin/pip install tox isort <- don't do that! (see explanation in note below)
sudo ../bin/pip freeze

Optional: prepare a config file for mr.bob

cat <<'EOF' | sudo tee my_mrbob.ini
[variables]
author.name = authorname
author.email = mail@domain.com
author.github.user = gituser
package.description = your description
package.git.init = False
plone.version = 5.2.6
python.version = python3.9
vscode_support = False
EOF

and call mrbob with your config file:

sudo ../bin/mrbob --config my_mrbob.ini -O my.package bobtemplates.plone:addon

Then add your package to zeocluster/develop.cfg as follows

eggs =
    Plone
    ...
    my.package
...
[sources]
my.package = fs my.package path=src

and run buildout

sudo -u buildout_user /home/Plone-5.2.6/zeocluster/bin/buildout -c /home/Plone-5.2.6/zeocluster/develop.cfg

note:
If I run sudo ../bin/pip install tox isort then running buildout with -u buildout_user will fail. You must then run buildout as plain sudo, i.e. without -u buildout_user. You maybe want to do so or maybe not.