[Google Colaboratory]: Why can't I use and import a module/package after installing it from Github? - github

I installed the ismrmrd-python-tools succesfully after running the following command on Colab:
!pip install git+https://github.com/ismrmrd/ismrmrd-python-tools.git
Successfully built ismrmrd-python-tools
But when I want to import the module, I get the next message error:
ModuleNotFoundError: No module named 'ismrmrd'
I tried with other module names like 'ismrmrd-python-tools', 'ismrmrdtools', etc. as well.
Does someone know anything about what could possibly be happening here?

I try it and it works without any problems.
!pip install git+https://github.com/ismrmrd/ismrmrd-python-tools.git
import ismrmrdtools

Related

Error when installing pycaret (jinja2) on Colab

I'm trying to use pyCaret on Colab. This is the setup:
!pip install pycaret
from pycaret.classification import *
grid = setup(data=s, target=s.columns[-1], html=False, silent=True, verbose=False)
best_model = compare_models()
However, I get this error on from pycaret.classification import *:
ImportError: Missing optional dependency 'Jinja2'. DataFrame.style requires jinja2. Use pip or conda to install Jinja2.
I've already followed this instruction unsuccessfully. Unable to resolve import error from PyCaret
Any clue?
If anyone else facing this issue and if its not work like author said try ;
pip install pycaret --user
after execution of code chunk done click *restart runtime button. after install if its succesfully import libraries skip markupsafe phase.
pip install markupsafe==2.0.1
after execution of code chunk done click *restart runtime button.
import jinja2
from pycaret.classification import *
You can also just install Jinja2 manually to solve this problem:
https://github.com/pycaret/pycaret/issues/2490

ImportError: cannot import name 'StopLocust' from 'locust.exception'

I'm getting an ImportError attempting to run a Locust/Selenium script: ImportError: cannot import name 'StopLocust' from 'locust.exception'
Is there a package that I need to install?
from realbrowserlocusts import ChromeLocust
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from locust_plugins.users import WebdriverUser
from locust.exception import StopLocust
import os
from locust import TaskSet, task
The output from the Terminal window shows this:
File "c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\realbrowserlocusts\core.py", line 6, in
from locust.exception import StopLocust
ImportError: cannot import name 'StopLocust' from 'locust.exception' (c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\locust\exception.py)
Any ideas?
If you're using Locust 1.0+ there is no StopLocust in locust.exceptions. I'm not sure what it is you're looking to do so I don't know if it's the right thing for you to use, but there is StopUser in there that you should be able to import.
Local environment issue. Re-installing my setup.
After doing some more research I was able to resolve a couple of issues from the import error. Installing locustio solved the import issue and a follow-on issue in attempting to load the locust web page was solved by updating gevent.
So, for the full fix uninstall the current version of locust and install the locustio version. Then upgrade the gevent.
pip uninstall locust
pip install locustio==0.14.6
pip install --upgrade gevent
Realbrowserlocusts isn't compatible with the most recent versions of Locust. Downgrading to version locust 0.13.5 fixed the issue. I'm not sure exactly which of the most recent versions of locust supports realbrowserlocusts. I would like to find out though so I'm running the best of locust versions supporting running with selenium.

Unable to import module in Google Colab after installing

I was trying to clone and install the Google Unrestricted adversarial examples repository following the instructions provided here. But I am unable to import the any of the modules. First I cloned the repository and changed to that directory.
!git clone https://github.com/google/unrestricted-adversarial-examples.git
cd unrestricted-adversarial-examples
Then I used the pip install command.
!pip -e install bird-or-bicycle
The installation completed without any error. However, when I try to import I get the 'module not found error'. Could anyone tell me what I am doing wrong? I tried the same commands on my PC and it works.
import bird_or_bicycle
ModuleNotFoundError: No module named 'bird_or_bicycle'
I just got the solution after posting an issue to the repository. The solution was simple, all I needed to do was restart the Colab kernel (Restart Runtime option in the Runtime tab) after !pip -e install bird-or-bicycle Apparently that is required to pick up the newly installed package.
If you look at the bird-or-bicycle docs, you see that there is a data download step required after you pip install.
If you follow the instructions there and run the following in a notebook cell, then the import will work:
!git clone https://github.com/google/unrestricted-adversarial-examples
!pip install -e unrestricted-adversarial-examples/bird-or-bicycle
!bird-or-bicycle-download

how to import h5py on datalab?

Does anybody know how to install h5py on datalab? pip install h5py doesn't work. apt-get install python-h5py is working in the shell but it doesn't recognize the package in datalab notebook!
Thnaks
It is true that !pip install h5py wil allow you to install the library but unfortunately, even after a successful installation, the import will fail:
The issue is rooted on an ongoing python-future issue ("surrogateescape handler broken when encountering UnicodeEncodeError") that is experienced in datalab because the underlying OS uses an 'ANSI_X3.4-1968' file system encoding.
As a hacky workaround, you may remove line 60 from h5py's __init__.py by running the following command from within a notebook cell:
!sed -i.bak '/run_tests/d' /usr/local/lib/python2.7/dist-packages/h5py/__init__.py
Just make sure you run it using bash syntax: !pip install h5py in any notebook cell.

anaconda packages installed but not found

I have a new macbook air running yosemite and I have installed Anaconda.
I want to practise on making GUIs with either wxpython.
When I run " conda list" wxpython is there, but when I import it I get "No module named wxpython" .
Any ideas how to fix this? Anaconda is added to my path in the bash_profile.
Regards
According to this it looks like the correct way to import this package is import wx. Try that.
It's possible you might run into a cairo error like this:
ImportError: /usr/lib64/libpangocairo-1.0.so.0: undefined symbol: cairo_ft_font_options_substitute. I was able to get around this by installing the cairo package via conda install -c https://conda.anaconda.org/pmuller cairo.