BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
933 stars 156 forks source link

Import error ModuleNotFoundError on Colab #40

Closed pschaldenbrand closed 2 years ago

pschaldenbrand commented 2 years ago

Hi! I recently ran into a ModuleNotFoundError error using DiffVG on Colab. I had no trouble just last week, but for some reason, this week I get this error. Any help resolving it would be greatly appreciated!

Here is a Colab notebook to recreate the error: https://colab.research.google.com/drive/1eGNOIl5fbZ-LoVOgODZ4cILY4wRqU9OK?usp=sharing

The import error:

ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-1-5a80a68a63c6>](https://localhost:8080/#) in <module>()
----> 1 import pydiffvg

ModuleNotFoundError: No module named 'pydiffvg'

There was an error during insallation that may be relevant: Traceback (most recent call last): File "setup.py", line 98, in zip_safe = False) File "/usr/local/lib/python3.7/dist-packages/setuptools/init.py", line 153, in setup return distutils.core.setup(**attrs) File "/usr/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.7/dist-packages/setuptools/command/install.py", line 67, in run self.do_egg_install() File "/usr/local/lib/python3.7/dist-packages/setuptools/command/install.py", line 109, in do_egg_install self.run_command('bdist_egg') File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.7/dist-packages/setuptools/command/bdist_egg.py", line 164, in run cmd = self.call_command('install_lib', warn_dir=0) File "/usr/local/lib/python3.7/dist-packages/setuptools/command/bdist_egg.py", line 150, in call_command self.run_command(cmdname) File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.7/dist-packages/setuptools/command/install_lib.py", line 11, in run self.build() File "/usr/lib/python3.7/distutils/command/install_lib.py", line 109, in build self.run_command('build_ext') File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "setup.py", line 31, in run super().run() File "/usr/local/lib/python3.7/dist-packages/setuptools/command/build_ext.py", line 79, in run _build_ext.run(self) File "/usr/local/lib/python3.7/dist-packages/Cython/Distutils/old_build_ext.py", line 186, in run _build_ext.build_ext.run(self) File "/usr/lib/python3.7/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/usr/local/lib/python3.7/dist-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions _build_ext.build_ext.build_extensions(self) File "/usr/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions self._build_extensions_serial() File "/usr/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial self.build_extension(ext) File "setup.py", line 65, in build_extension subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) File "/usr/lib/python3.7/subprocess.py", line 363, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j8']' returned non-zero exit status 2.

henryleemr commented 2 years ago

Looking for a solution to this too if it's possible! D:

henryleemr commented 2 years ago

Hello @pschaldenbrand did you manage to find a solution? Still stuck here getting it on Colab sadly

GinYoshida commented 2 years ago

@pschaldenbrand @henryleemr I can make your colab working with adding the following code before running the codes or yours.

import os
os.kill(os.getpid(), 9)

%tensorflow_version 1.x

I suppose just restart of runtime could be OK. When I opened your notebook, the working directory was not "contents". It will cause the problem of diffvg directory structure...

pschaldenbrand commented 2 years ago

@GinYoshida Thank you so much!! The key detail to fixing the installation error was adding %tensorflow_version 1.x before installation. I just put it as the first line of my notebook and make sure that I restart the notebook after diffvg installs. No more problems. Thank you again :)