I am trying to import Localization library in python 3.7 in Jupyter notebooks but everytime it shows this error:
ModuleNotFoundError
Traceback (most recent call last)
<ipython-input-6-ca0ae5a2ecfb> in <module>()
2 from skimage.measure import regionprops
3 import matplotlib.patches as patches
----> 4 import localization
~\Anaconda3\lib\site-packages\localization\__init__.py in <module>()
----> 1 from geoProject import *
ModuleNotFoundError: No module named 'geoProject'
I have no project named 'geoProject' either.
It is not your fault. geoProject seems to be another file in that project.
https://github.com/kamalshadi/Localization/blob/master/localization/geoProject.py
It is not being imported correctly inside the localization module at the __init__.py file
Related
I'm unable to install stackstac on Google Colab. This is reproducible with the code below.
!pip install stackstac
import stackstac
outputs:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-c01f370957f7> in <module>()
1 get_ipython().system('pip install stackstac')
----> 2 import stackstac
1 frames
/usr/local/lib/python3.7/dist-packages/stackstac/rio_reader.py in <module>()
5 import threading
6 import weakref
----> 7 from typing import TYPE_CHECKING, Optional, Protocol, Tuple, Type, Union
8
9 import numpy as np
ImportError: cannot import name 'Protocol' from 'typing' (/usr/lib/python3.7/typing.py)
---------------------------------------------------------------------------
Same issue on a local instance how ever that solution doesn't translate.
Protocol was introduced to typing as of Python 3.8, as can be seen in the docs. You appear to be running Python 3.7, based on your file paths - upgrade to use Python 3.8 or later if you can.
I was receiving the following error. I have installed the package in the pycharm. Now the module is available in main.py file but the module is not available in jupyter notebook that I am using in pycharm.
When I run the cell I still get the following error in jupyter notebook but not in main.py file.
Please help me out!
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-7a030bc34e9f> in <module>
----> 1 from sklearn.cluster import KMeans
2 import numpy as np
3
4 from sklearn.cluster import KMeans
5 import numpy as np
ModuleNotFoundError: No module named 'sklearn'
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
I am having some difficulty trying to get the linear_algebra module working on Jupyter Notebook in Python. I am trying:
import linear_algebra
But I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-30-7080be6cdc0f> in <module>()
----> 1 import linear_algebra
ImportError: No module named 'linear_algebra'
I don't get what I am doing wrong
Thank you in advanced for help
The 'linear_algebra' is not a library so you can't simply import it as such. It is a file that has the functions (eg. dot) so you have to make sure your main code file and the linear_algebra.py is at the same directory. I hope this helps.
I am having a problem running below code in python;
from helpers import process_titanic_line
print(process_titanic_line(lines[0]))
The error which I am getting is;
ImportError Traceback (most recent call last)
<ipython-input-29-56917437b562> in <module>()
1 #NOT WORKING
2
----> 3 from helpers import process_titanic_line
4 print(process_titanic_line(lines[0]))
ImportError: No module named helpers
Any help will be greatly appreciated.
Thank you
I had to upload helpers module to python. I did it by uploading helpers.py file for the project. I would like to thank all who contributed to the discussion.