ElPapi42
ElPapi42

Reputation: 524

Cant install custom package in Google Colab

i have a custom package written by myself called deblurrer, it is a bunch of script for train a neural network.

In Google Colab, i cloned my repo successfully, i have all the required stuff for execute the setup.py module and install deblurrer 1.0.0. When i install deblurrer locally in my pc, everything works as expected, but when i try to run !python setup.py install in Colab, nothing is installed, in fact, the output says everything is fine, but i cant import the package. Execute the next code in two separate Colab Cells for reproduce the issue:

# Cell 01
# Executes the cell in bash mode
%%bash

git clone https://github.com/ElPapi42/deep-deblurring
python deep-deblurring/setup.py install
# Cell 02
import deblurrer

as you can see, the installation runs as espected, but when importing:ModuleNotFoundError: No module named 'deblurrer'

What can be wrong?

Upvotes: 5

Views: 5447

Answers (1)

SilentStone
SilentStone

Reputation: 537

You'll have to take a slightly different approach with Colab.

# 1. Download the repo and set it as the current directory
!git clone https://github.com/ElPapi42/deep-deblurring
%cd deep-deblurring

# 2. install the project/module
!python setup.py install

# 3. Add the project directory to the path
import os, sys
sys.path.append(os.getcwd())

#4. Run your code
# ....

As outlined here https://stackoverflow.com/a/53747334/2466781

Upvotes: 6

Related Questions