danmacnish/cartoonify

ImportError: cannot import name run

JBaczuk opened this issue · 8 comments

Installed on mac using $ pip install --user and trying to run with $ cartoonify, getting this error: ImportError: cannot import name run. Installed module run using $ pip install run --user

I'm getting the same error here too

This also fails on Ubuntu:

Traceback (most recent call last):
  File "/home/parallels/.local/bin/cartoonify", line 9, in <module>
    load_entry_point('cartoonify==0.1.0', 'console_scripts', 'cartoonify')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2239, in resolve
    raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'run'
v1993 commented

Ubuntu 18.04:

Traceback (most recent call last):
  File "/home/v/.local/bin/cartoonify", line 11, in <module>
    load_entry_point('cartoonify==0.1.0', 'console_scripts', 'cartoonify')()
  File "/home/v/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/v/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/home/v/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/home/v/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named run

I get around this issue by running cartoonify directly from the source cartoonify/ directory with python2.7 run.py.

For compatibility with Python 2.7 I also had to change line 127 of workflow.py from:

        with open(str(scores_path), 'w', newline='') as f:

to:

        with open(str(scores_path), 'w') as f:

Thirdly, the Path input for specifying input images did not work for me on osx. I changed line 76 in run.py from:

            path = Path(input("enter the path to the directory to process:"))

to:

            path = Path.cwd() / 'images'

With this modification, I place any number of input images in the images/ folder, and launch cartoonify with python2.7 run.py --batch-process.

It seems to actually be written for Python 3 (as evidenced by the use of input() instead of raw-input(), the newline parameter to open(), etc.), contrary to the documentation which says Python 2.7.

The README.md instructions now reflect some of what I wrote in my previous comment (latest commit 084146e).

@anders-dc your suggestions are spot on - I've since done a clean clone of the repo on my machine, and updated the readme and desktop reqs.

As I'm sure a few people have noticed, the desktop functionality and documentation is a bit lacklustre. I mostly only ran this on the desktop to help me debug the raspi. In fact, ensuring the code ran on the pi dictated quite a few of the seemingly odd aspects of the repo:

  • Python 2.7 was required for running on the pi because of the specific version of tensorflow required, along with the limited binaries available through APT.
  • Seperate requirements lists were required for pi and desktop installation, because of the above.

I'm really happy for anyone to submit pull requests to improve the desktop functionality.

python2 -m pip install run --user # forces the use of the pip linked to legacy Python even on a Mac that also has modern Python installed.