I want to acess m_rcnn.py file in jupyter notebook. The folder structure is as follows
collab_mask_rcnn(working directory). Inside this workinhg directory i have a folder name maskrcnn_colab and inside this maskrcnn_colab folder i have another folder named mrcnn_demo where i have all the python file like m_rcnn.py, config.py located which i am trying to import
import sys
sys.path.append('C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo')
from m_rcnn import *
When i excute this i get the following error
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-3841d2b3769e> in <module>
3 import sys
4 sys.path.append("C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo")
----> 5 from m_rcnn import *
6 get_ipython().run_line_magic('matplotlib', 'inline')
C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo\m_rcnn.py in <module>
19 # Import Mask RCNN
20 sys.path.append(ROOT_DIR) # To find local version of the library
---> 21 from mrcnn_demo.config import Config
22 from mrcnn_demo import utils
23 import mrcnn_demo.model as modellib
ModuleNotFoundError: No module named 'mrcnn_demo'
What am i missing?
I think you use sys.path.insert . Something like this:
from m_rcnn import *
import sys
sys.path.insert(1,'C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo')
You might just try it like this:
from maskrcnn_colab.mrcnn_demo.m_rcnn import *
Related
here is my code to import some python libraries:
from radmc3dPy import *
from radmc3dPy.image import *
from radmc3dPy.analyze import *
from radmc3dPy.natconst import *
import matplotlib.pyplot as plt
import numpy as np
import os
from astropy.io import fits
import matplotlib.gridspec as gridspec
On running the cell, I receive the following error even after factory resetting the runtime:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-225d47afe30d> in <module>()
----> 1 from radmc3dPy import *
2 from radmc3dPy.image import *
3 from radmc3dPy.analyze import *
4 from radmc3dPy.natconst import *
5 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'radmc3dPy'
you need to download and install the library before you can use it. I saw that there is a github for your package here: https://github.com/dullemond/radmc3d-2.0
in colab, you can install it with:
!git clone https://github.com/dullemond/radmc3d-2.0.git
%cd ./radmc3d-2.0/python/radmc3dPy/
!python setup.py install
%cd ~/../content
! and % are required.
The comand clones the desired directory from git, changes into the python directory, runs the setup of your package and changes your working directory back. Directly running the setup.py with the full path, did not work, hence changing the directory.
I would like to import this models to my python code
import os
import torch
import numpy as np
import sys
from datetime import datetime
from src.crowd_count import CrowdCounter
from src import network
from src.data_loader import ImageDataLoader
from src.timer import Timer
from src import utils
from src.evaluate_model import evaluate_model
when I run my code it shows this error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-14-e118d9908bd9> in <module>
5 from datetime import datetime
6
----> 7 from src.crowd_count import CrowdCounter
8 from src import network
9 from src.data_loader import ImageDataLoader
ModuleNotFoundError: No module named 'src'
I installed the crowdcount and also shows this error
the problem with src if I did only
import crowdcount it works fine
Try reinstalling it; checking it's source file OR checking what versions it supports
My issue is when trying to import the DCSBM model:
Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import hyppo
from hyppo.time_series import _utils as _utils
from graspy.embed import AdjacencySpectralEmbed
from graspy.models import DCSBMEstimator
from graspy.models import EREstimator
from graspy.models import SBMEstimator
from graspy.models.sbm import _block_to_full, _get_block_indices
from graspy.simulations import er_np, sbm
Error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-33-287386449480> in <module>()
8 from hyppo.time_series import _utils as _utils
9 from graspy.embed import AdjacencySpectralEmbed
---> 10 from graspy.models import DCSBMEstimator
11 from graspy.models import EREstimator
12 from graspy.models import SBMEstimator
2 frames
/usr/local/lib/python3.7/dist-packages/graspy/inference/latent_distribution_test.py in <module>()
26 from sklearn.metrics.pairwise import PAIRWISE_KERNEL_FUNCTIONS
27 from hyppo.ksample import KSample
---> 28 from hyppo._utils import gaussian
29
30 _VALID_DISTANCES = list(PAIRED_DISTANCES.keys())
ModuleNotFoundError: No module named 'hyppo._utils'
---------------------------------------------------------------------------
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 think hyppo._utils doesn't exist and has been replaced by hyppo.time_series and inside that folder there exists the required _utils package.
How do we fix this?
I was just trying to run the tutorial: https://docs.neurodata.io/notebooks/pedigo/graspologic/2020/09/24/latent_model_tutorial.html
Run on Google colab
This line
from hyppo.time_series import _utils as _utils was added from me trying to fix the issue, but doesn't work.
Looks like you're using an old version of the package - it's called "graspologic" now. If you pip install graspologic, from graspologic.models import DCSBMEstimator should work fine. Just replace everything in that code that says "graspy" with "graspologic".
we're happy to answer questions on github issues as well! (I'm one of the people who contributes to the package)
I installed the library Mouse in a virtual environment through the conda prompt, and while importing the lib.mouse library, results in an error.
import argparse
import datetime
import imutils
import time
import cv2
import numpy as np
from lib.mouse import Mouse
from lib.video_source import getVideoSource
from lib.polygon import drawQuadrilateral
from lib.user_interaction import getPerpectiveCoordinates
from lib.fgbg_calculations import getThresholdedFrame
from lib.heatmap import Heatmap
from lib.coordinate_transform import windowToFieldCoordinates
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-d5f001ef6688> in <module>
5 import cv2
6 import numpy as np
----> 7 from lib.mouse import Mouse
8 from lib.video_source import getVideoSource
9 from lib.polygon import drawQuadrilateral
ModuleNotFoundError: No module named 'lib.mouse'
I am assuming you copy your code from https://github.com/dev-labs-bg/football-stats
In the repo, there is a folder called lib. You need to copy that too. It's not part of opencv library, it's a python module from that repo.
I have written a package named biographs with the following architecture:
biographs (folder)
>biographs (package)
>__init__.py
>bpdb.py
>pmolecule.py
>bgraph.py
>bspace.py
The __init__.py file is only the following:
from .pmolecule import Pmolecule
When I'm working in ipython3 and I want to import biographs (only to use the class Pmolecule), I get the following error in ipython3 (Ipython 6.0.0, Python 3.6.1):
In [1]: cd ~/biographs/
/Users/rdora/biographs
In [2]: import biographs
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-1803e6928e0e> in <module>()
----> 1 import biographs
/Users/rdora/biographs/biographs/__init__.py in <module>()
----> 1 from .pmolecule import Pmolecule
/Users/rdora/biographs/biographs/pmolecule.py in <module>()
1 # class to deal with protein structures
2 # python 2
----> 3 import bpdb
4 import bgraph
5 import bspace
ModuleNotFoundError: No module named 'bpdb'
However when I do exactly the same process using IPython 5.3.0 with Python 2.7.13 there is no error message.
Thank you
This is because of how imports work in Python 2 and Python 3. In your module pmolecule.py you apparently do import bpdb. In Python 2 this will search the local directory for a module called bpdb.py and import it. However in Python 3 you must be explicit about those relative imports, i.e. you need to do
from . import bpdb
In order to get consistency for Python 2 you can use from __future__ import absolute_imports which prohibits such non-explicit imports also under Python 2.
Note that the same holds for:
----> 3 import bpdb
4 import bgraph
5 import bspace
Those need to be imported via from . import <module-name> syntax.
Further reading
What's new in Python 3 -- Removed Syntax
PEP 328 -- Imports: Multi-Line and Absolute/Relative