ModuleNotFoundError: No module named 'pytorch3d' - Simplified Disco Diffusion - python

I was running this Google Colab today everything was working fine but eventually I starting getting these errors in the Set Up Environment. I can't find a fix. Any help would be appreciated let me know if I need to provide more info.
Here's a link to the colab: https://colab.research.google.com/github/entmike/disco-diffusion-1/blob/main/Simplified_Disco_Diffusion.ipynb
📁 Google Drive already mounted.
✅ Disco Diffusion root path will be "/content/gdrive/MyDrive/disco-diffusion-1"
Google Colab detected.
📄 Pulling updates from GitHub...
M download_models.sh
M examples/docker/disco-file.sh
M examples/docker/disco.sh
M examples/docker/interactive.sh
M examples/docker/unittest.sh
M examples/linux/configfile.sh
M examples/linux/simple.sh
Your branch is up to date with 'origin/main'.
Already up to date.
📦 Upgrading pyyaml...
📦 Installing pip requirements...
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-11-4fe875dbbe21> in <module>()
70 # Import DD helper modules
71 sys.path.append(PROJECT_DIR)
---> 72 import dd, dd_args
73
74 # Unsure about these:
1 frames
/content/gdrive/MyDrive/disco-diffusion-1/disco_xform_utils.py in <module>()
3
4 # import pytorch3dlite.pytorch3dlite as p3d
----> 5 from pytorch3d import renderer
6 from midas import utils as midas_utils
7 from PIL import Image
ModuleNotFoundError: No module named 'pytorch3d'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
--------------------------------------------------------------------------- ```

I've opened an issue with the author of the repo (here).
In the meantime, open the "Set Up Environment" cell and update the section under "if is_colab" like so:
#Upgrade pyyaml if in Colab
if is_colab:
print(f'📦 checking out specific commit...')
for cmd in ['git clean -df', f'git reset --hard 3fc1dddb043f7f814db49fe951b4abb7eebd22fd', f'git log -1']:
gitresults = subprocess.run(f'{cmd}'.split(' '), stdout=subprocess.PIPE).stdout.decode("utf-8")
print(f'{gitresults}')
print(f'📦 Upgrading pyyaml...')
subprocess.run(f'pip install --upgrade pyyaml --quiet'.split(' '), stdout=subprocess.PIPE).stdout.decode("utf-8")
print(f'📦 Installing pip requirements...')
subprocess.run(f'pip install -r colab-requirements.txt --quiet'.split(' '), stdout=subprocess.PIPE).stdout.decode("utf-8")
what this does is it reverts the last commit which appears to have broken things.
Just re-run the cell (and the ones after)... it works for me.

It's fixed now. Thanks for reporting it!

Related

chembl_webresource_client install failed on google colab

need your help, I tried to install the chembl_webresource_client on colab, it usually works fine, but today to my surprise there is a mistake in the very first step.
! pip install chembl_webresource_client # install the client
from chembl_webresource_client.new_client import new_client # here is where is wrong
molecule = new_client.molecule
res = molecule.search('viagra')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-19aed0e54aea> in <module>()
----> 1 from chembl_webresource_client.new_client import new_client
2 molecule = new_client.molecule
3 res = molecule.search('viagra')
4 frames
/usr/local/lib/python3.7/dist-packages/chembl_webresource_client/cache.py in <module>()
1 __author__ = 'mnowotka'
2
----> 3 from requests_cache.backends.base import BaseCache, hashlib, _to_bytes
4
5 def create_key(self, request):
ImportError: cannot import name 'hashlib' from 'requests_cache.backends.base' (/usr/local/lib/python3.7/dist-packages/requests_cache/backends/base.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
This is an issue with requests-cache. I downgraded to 0.5.2 and the error goes away.
This issue was fixed on version 0.10.3 of the chembl_webresource_client. Upgrading should fix it

Import own Python module on Kaggle

I am new to this and very new to Kaggle.
I am trying to replicate this notebook:
https://www.kaggle.com/bibhash123/chest-x-ray-abnormalities-baseline-tf-keras
There one person wrote a module from utilities_x_ray
https://www.kaggle.com/bibhash123/utilities-x-ray
How to import it? It looks like utilities_x_ray is not directly specified in the second link.
As a result, I get an error
ERROR: Could not find a version that satisfies the requirement utilities_x_ray
ERROR: No matching distribution found for utilities_x_ray
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-14-79d7808e32c5> in <module>
11 import matplotlib.pyplot as plt
12 get_ipython().system('pip install utilities_x_ray')
---> 13 import utilities_x_ray
14 from utilities_x_ray import read_xray,showXray
15 from tqdm import tqdm
ModuleNotFoundError: No module named 'utilities_x_ray'
You do not need to pip install the utility file. Rather, just include the utilities_x_ray.py file in the same directory that you run the python notebook.
The python notebook looks for files within the same directory whenever importing as well as those modules that were installed via pip.
You need to copy the script content from https://www.kaggle.com/bibhash123/utilities-x-ray into your working directory and save it as utilities_x_ray.py
Hope this w'll be helpfull
You should consider downloading both the chest-x-ray-abnormalities-baseline-tf-keras.ipynb as and the utilities_x_ray.py Please make sure that they are into the same folder... After that, you'll need to install the pydimcom and scikit-image using pip install pydicom scikit-image
You can also install the packages directly from the GIt repository:
!pip install git+https://github.com/dkriegner/xrayutilities.git

Submodule import not working on Google Colab

I have a package called boo which I install on google colab from a github repository. The installation process looks fine and results in success message Successfully installed boo-0.1. However import boo fails on first internal import.
I replicated the same installation steps in a local virtual environment and package worked, but not on collab.
Here are my steps and error trace:
!rm -rf sandbox
!git clone https://github.com/ru-corporate/sandbox.git
!pip install -r sandbox/requirements.txt
!pip install sandbox/.
Alternatively, I tried
!pip install git+https://github.com/ru-corporate/sandbox.git#master
The error trace is:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-fc0b1d036b35> in <module>()
----> 1 import boo
/usr/local/lib/python3.6/dist-packages/boo/__init__.py in <module>()
----> 1 from boo.boo import download, build, read_dataframe, files
2 from boo.views.whatis import whatis
/usr/local/lib/python3.6/dist-packages/boo/boo.py in <module>()
3 from tqdm import tqdm
4
----> 5 from boo.file.download import curl
Basically, from root __init__.py the import goes to root boo.py and stumbles upon finding boo/file/download.py.
How do I make this package work on collab?
I could fix the subpackage behavior by editing setup.py as suggested here:
# ...
packages=setuptools.find_packages()
# ...
Somehow Colab is more restrictive on this parameter than local installation.

Unable to find module qiskit_aqua.algorithms

pip-install qiskit-aqua completed successfully.
Following is ths stack trace:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-8f03022943b2> in <module>()
2 import sys
3 from datasets import *
----> 4 from qiskit_aqua.algorithms.many_sample.qsvm.data_preprocess import *
5 from qiskit_aqua.input import get_input_instance
6 from qiskit_aqua import run_algorithm
ModuleNotFoundError: No module named 'qiskit_aqua.algorithms'
After some searching, I found the code that you're running: it appears to come from one of the tutorials in the repository at https://github.com/Qiskit/aqua-tutorials. The current version of this repository is compatible with the current master branch of the Qiskit Aqua repository at https://github.com/Qiskit/aqua, which is currently somewhat ahead of the latest version available on PyPI (i.e. the one you installed using PIP). I expect PyPI will be updated with the latest version soon, but in the meantime I'd recommend that you clone the master branch of the Qiskit Aqua repository from GitHub. You can then install it using pip install -e if desired.

Import of matlab.engine works in IPython but not in Jupyter

I just installed the MATLAB Engine API for Python to my home directory using
$ python setup.py build --build-base=$HOME install --prefix=$HOME
However, when I try to import matlab.engine from a Jupyter notebook, I get the following error:
---------------------------------------------------------------------------
EnvironmentError Traceback (most recent call last)
<ipython-input-2-833daa01cd46> in <module>()
8 import numpy as np
9 import matplotlib.pyplot as plt
---> 10 import matlab.engine
11
12 from dopa_net.behavioral_experiments.analysis_code import behavior_analysis as ba
/home/despo/dbliss/lib/matlab/engine/__init__.py in <module>()
57 pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
58 except:
---> 59 raise EnvironmentError('The installation of MATLAB Engine for Python is '
60 'corrupted. Please reinstall it or contact '
61 'MathWorks Technical Support for assistance.')
EnvironmentError: The installation of MATLAB Engine for Python is corrupted. Please reinstall it or contact MathWorks Technical Support for assistance.
Oddly, I don't get this error when I import matlab.engine from within an IPython shell in the same directory as the Jupyter notebook. Not only can I import the engine from the shell -- it works in the shell, which demonstrates to me that nothing is corrupted:
In [1]: import matlab.engine
In [2]: eng = matlab.engine.start_matlab()
In [3]: tf = eng.isprime(37)
In [4]: print tf
True
Any ideas what's going on?
N.B. I did install a version of the engine to my home directory earlier today, but I tried to (and thought I did) uninstall it. My guess is some part of it has been left behind and is causing trouble. But why is it causing trouble only for Jupyter, and not for the IPython shell? (And how would you guess I should get rid of it?)
Update
I tracked the error to the following line in the __init__.py file for the matlab.engine module:
importlib.import_module("matlabengineforpython2_7")
which does not raise an error in the IPython shell, but does raise the following error in Jupyter:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-831d184262c4> in <module>()
----> 1 importlib.import_module("matlabengineforpython2_7")
/usr/local/anaconda-2.4.0/lib/python2.7/importlib/__init__.pyc in import_module(name, package)
35 level += 1
36 name = _resolve_name(name[level:], package, level)
---> 37 __import__(name)
38 return sys.modules[name]
ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /srv/local/matlab-2015a/extern/engines/python/dist/matlab/engine/glnxa64/../../../../../../../bin/glnxa64/libmwfl.so)
I have no idea what's going on here.
The hypothesis that the IPython Shell and Jupyter Notebook don't have access to the same C libraries seems to have been correct. Why this is the case, I have no idea. The two were installed as part of the same package, use the same version of Python, etc.
Adding the following line to my .bashrc shell configuration file fixed the issue:
export LD_LIBRARY_PATH=XXX
where XXX is the directory containing the version of libstdc++.so.6 I want the Jupyter Notebook to use (and that the IPython Shell already uses).

Categories

Resources