Cannot use ssd.pytorch package in google colab - python

I am trying to use this package ssd.pytorch in google colab but it is not working. I have added image of the code in the last line of the post. Here's my code-
import torch
from torch.autograd import Variable
import cv2
!git clone https://github.com/amdegroot/ssd.pytorch.git #cloning the package in colab first
!pip install -q BaseTransform
from data import BaseTransform, VOC_CLASSES as labelmap
whenever I try to install BaseTransform this message shows up.
Could not find a version that satisfies the requirement BaseTransform (from versions: )
No matching distribution found for BaseTransform
So I can't import anything. Should I install what I cloned first? But when I try to install ssd.pytorch the same message shows up.
!pip install -q ssd.pytorch
Could not find a version that satisfies the requirement ssd.pytorch (from versions: )
No matching distribution found for ssd.pytorch
As I am importing from the folder data should I install using that folder name?
!pip install -q data
For some reason this works and I don't know why. But still can't import anything when I use this line.
from data import BaseTransform, VOC_CLASSES as labelmap
ImportError Traceback (most recent call last)
in ()
----> 1 from data import BaseTransform, VOC_CLASSES as labelmap. ImportError: cannot import name 'BaseTransform'
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.
What should I do to import the package properly?
This is what the code looks like in colab:

the problem you got, is because you haven't change directory before import package.
just run the code below before you import
import os
os.chdir('ssd.pytorch')
besides, BaseTransform is a class defined in ssd.pytorch/data. You cannot install it.

Related

ModuleNotFoundError: No module named 'hcaptcha'

I am trying to execute a code of mine, but i keep getting the following error:
ModuleNotFoundError: No module named 'hcaptcha'
When I try installing 'hcaptcha' from pip install hcaptcha, it say this:
ERROR: Could not find a version that satisfies the requirement hcaptcha (from versions: none)
ERROR: No matching distribution found for hcaptcha
I tried installing captcha and recaptcha too, but the error was still the same that hcaptcha module is not found.
Here is the bit of my code which is affected:
from tensorflow.keras.models import load_model
import cv2, hcaptcha
import numpy as np
model = load_model('./data/data.h5')
i will not show rest of it, only this much of it is important since this contains the import hcaptcha
The hcaptcha library is one made by h0nde
Just Install With The Following:
(Make Sure You Have Git Installed)
pip install -U git+https://github.com/h0nde/py-hcaptcha

Trouble installing/importing "scanpy" dependency in Python

I'm having trouble importing a python package called "scanpy" into a Jupyter Notebook. Following #ecjb's advice here (Python - package not found although it is installed), which was basically to specify the python/pip installation I wanted to use when installing "joblib," I've tried to specify the pip and python and install joblib but I can't seem to get it working.
import numpy as np
import pandas as pd
!/software/miniconda3/4.10.3/bin/pip install joblib
import joblib
import scanpy as sc
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Requirement already satisfied: joblib in /home/atp9753/.local/lib/python3.9/site-packages (1.1.0)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-9bd6abfc0151> in <module>
2 import pandas as pd
3 get_ipython().system('/software/miniconda3/4.10.3/bin/pip install joblib')
----> 4 import joblib
5 import scanpy as sc
ModuleNotFoundError: No module named 'joblib'
I've also tried deleting my virtual environment and recreating it, and several other things. If someone could offer some help, I would be really grateful.
EDIT:
This seems to me to be the oddest error:
~/.local/lib/python3.6/site-packages/sklearn/utils/_joblib.py in <module>
6 # versions
7 import joblib
----> 8 from joblib import logger
9 from joblib import dump, load
10 from joblib import __version__
By installing it from the source, I've got it to import "joblib" but now it won't install joblib's modules. Does anyone happen to know a reason for this?
To get the latest code using git, just type:
git clone git: //github.com/joblib/joblib.git
If you don't have git installed, you can download a zip or tarball of the latest code:
http://github.com/joblib/joblib/archives/master
After installing git, proceed to install joblib from the directory
example:
python setup.py installation
try this way to see

Load a package from github and url ending in .git

I try to import a Python package from github. I am working in Google Colab.
The repository is at the following url https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp.
So I use the following code
!pip install --upgrade
!pip install -q git+git://github.com/microsoft/nlp-recipes/tree/master/utils_nlp
from utils_nlp import *
I tried as well
!pip install -q git+https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp
I saw other (working) examples where the url ends in .git :
!pip install -q git+https://github.com/huggingface/transformers.git
so I tried in turn
!pip install -q git+https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp.git
But I also noticed that https://github.com/microsoft/nlp-recipes/tree/master/utils_nlp.git loads to an error page while https://github.com/huggingface/transformers.git load to https://github.com/huggingface/transformers which surprises me.
How do we load the Python package here ?
EDIT
I am using as suggested
pip install git+https://github.com/microsoft/nlp-recipes.git
then
from utils_nlp import *
works but it doesn't successfully import subfolders, it fails when I do
from utils_nlp.models.transformers.abstractive_summarization_bertsum \
import BertSumAbs, BertSumAbsProcessor
whereas utils_nlp does contain a folder models which in turn contains transformers
The error stack is then the following
/usr/local/lib/python3.7/dist-packages/utils_nlp/models/transformers/abstractive_summarization_bertsum.py in <module>()
15 from torch.utils.data.distributed import DistributedSampler
16 from tqdm import tqdm
---> 17 from transformers import AutoTokenizer, BertModel
18
19 from utils_nlp.common.pytorch_utils import (
ModuleNotFoundError: No module named 'transformers'
So strangely code in utils_nlp.models.transformers.abstractive_summarization_bertsum doesn't resolve the dependency to transformers
This is the correct way to install it:
pip install git+https://github.com/microsoft/nlp-recipes.git
You can't install a module, only a package can be installed. After the installation you can go on with the rest of your code
from utils_nlp import *
...
As you can read in the setup guide (which you should definitely read when installing a package):
The pip installation does not install any of the necessary package dependencies, it is expected that conda will be used as shown above to setup the environment for the utilities being used.
This explains your error: the transformers package is not installed automatically, you need to install it on your own (simply use pip install transformers). This is also confirmed in the setup.py file: the are no "install_requires" dependencies.

Multiple errors importing and using mglearn

I'm getting multiple errors trying to install and import the mglearn library into a Jupyter notebook. I've installed mglearn using the command line using pip install mglearn and also directly into Jupyter using !pip install mglearn. However, when I try to import mglearn I get the error ModuleNotFoundError: No module named 'mglearn'. If I try to install it again I get a Requirement already satisfied response.
I then went into the python terminal with $python3 and tried import mglearn, which was successful. I checked the version and I get 0.1.7.
I've also tried the following code within Jupyter:
import sys
!{sys.executable} -m pip install mglearn
With that code I get a zsh:1: no matches found: error.
I know it's installed and I'm importing it. I'm out of ideas for how to fix this. Any help would be appreciated.

Cannot import or install pandas-profiling in Jupyter Notebook

I have technically already installed pandas-profiling using
pip install pandas-profiling
But when I try to import it, I get the following error:
import numpy as np
import pandas as pd
import pandas_profiling
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e1a23f2a6f04> in <module>()
1 import numpy as np
2 import pandas as pd
3 import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'
First Error Image
So I tried installing it in Jupyter Notebook and got the following error as well:
import sys
!{sys.executable} -m pip install pandas-profiling
Collecting pandas-profiling
Could not find a version that satisfies the requirement pandas-profiling
(from versions: )
No matching distribution found for pandas-profiling
Second Error Image
I am also unable to install it using conda for both as I am unable to establish a connection to conda.anaconda.org for some reason.
To others who are looking to resolve this issue try these alternate steps :
Run pip install pandas-profiling command in a separate cell in the jupyter notebook.
After this just restart the kernal and run again. This should definitely work. Worked for me.
Based on the comments I was able to figure out the issue. I had to install jupyter notebook outside of the Anaconda root env and open it from the terminal.
pip3 install jupyter notebook
Once I did that it imported properly.
Steps:
Download the ZIP
Open Anaconda Prompt and go to the directory and extract the files to a folder
cd
C:\Users\farah\Downloads\pandas-profiling-master\pandas-profiling-master
Then type python setup.py install
Now you can use:
import pandas_profiling as pp
df = pd.read_csv('1234.csv')
pp.ProfileReport(df)
Reference: Pandas profiling
!pip install pandas_profiling # Run this from Jupytor notebook Ignore the warnings if any
from pandas_profiling import ProfileReport #restart the kernel if throws error
ProfileReport(df)
Note: This worked for me on Windows 10
From Anaconda Prompt:
conda install -c conda-forge pandas-profiling

Categories

Resources