I'm trying to train Mask-R CNN model from cocoapi(https://github.com/cocodataset/cocoapi), and this error code keep come out.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-83356bb9cf95> in <module>
19 sys.path.append(os.path.join(ROOT_DIR, "samples/coco/")) # To find local version
20
---> 21 from pycocotools.coco import coco
22
23 get_ipython().run_line_magic('matplotlib', 'inline ')
~/Desktop/coco/PythonAPI/pycocotools/coco.py in <module>
53 import copy
54 import itertools
---> 55 from . import mask as maskUtils
56 import os
57 from collections import defaultdict
~/Desktop/coco/PythonAPI/pycocotools/mask.py in <module>
1 __author__ = 'tsungyi'
2
----> 3 import pycocotools._mask as _mask
4
5 # Interface for manipulating masks stored in RLE format.
ModuleNotFoundError: No module named 'pycocotools._mask'
I tried all the methods on the github 'issues' tab, but it is not working to me at all. Is there are another solution for this? I'm using Python 3.6, Linux.
The answer is summarise from these three GitHub issues
1.whether you have installed cython in the correct version. Namely, you should install cython for python2/3 if you use python2/3
pip install cython
2.whether you have downloaded the whole .zip file from this github project. Namely, you should download all the things here even though you only need PythonAPI
git clone https://github.com/cocodataset/cocoapi.git
or
unzip the zip file
3.whether you open Terminal and run "make" under the correct folder. The correct folder is the one that "Makefile" is located in
cd path/to/coco/PythonAPI/Makefile
make
Almost, the question can be solved.
If not, 4 and 5 may help.
4.whether you have already installed gcc in the correct version
5.whether you have already installed python-dev in the correct version. Namely you should install python3-dev (you may try "sudo apt-get install python3-dev"), if you use python3.
Try cloning official repo and run below commands
python setup.py install
make
Related
I've recently had to do a reformat of my work computer, and am reinstalling Anaconda. I generally keep Anaconda's root (base) folder untouched, and create separate environments when I need to work with specialist Python modules instead of cluttering the (base) environment.
In the past, I was able to successfully run these different environments from the Jupyter Notebook installed in the (base) environment. I would go about doing so by installing ipykernel in the new environment (e.g. my-env), and then running the following commands:
(base) activate my-env
(my-env) conda install ipykernel
(my-env) python -m ipykernel install --name "my-env" --display-name "My Python"
This would be done successfully, and give me the following message:
Installed kernelspec my-env in C:\ProgramData\jupyter\kernels\my-env
However, when I tried testing out the link in Jupyter Notebook using a standard import matplotlib.pyplot as plt command, I get the following error message:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt
C:\Anaconda3\envs\my-env\lib\site-packages\matplotlib\__init__.py in <module>
105 # cbook must import matplotlib only within function
106 # definitions, so it is safe to import from it here.
--> 107 from . import cbook, rcsetup
108 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
109 from matplotlib.cbook import mplDeprecation # deprecated
C:\Anaconda3\envs\my-env\lib\site-packages\matplotlib\cbook\__init__.py in <module>
26 import weakref
27
---> 28 import numpy as np
29
30 import matplotlib
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\__init__.py in <module>
141 from .core import *
142 from . import compat
--> 143 from . import lib
144 # NOTE: to be revisited following future namespace cleanup.
145 # See gh-14454 and gh-15672 for discussion.
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\lib\__init__.py in <module>
23 # Private submodules
24 from .type_check import *
---> 25 from .index_tricks import *
26 from .function_base import *
27 from .nanfunctions import *
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\lib\index_tricks.py in <module>
9 from numpy.core.numerictypes import find_common_type, issubdtype
10
---> 11 import numpy.matrixlib as matrixlib
12 from .function_base import diff
13 from numpy.core.multiarray import ravel_multi_index, unravel_index
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\matrixlib\__init__.py in <module>
2
3 """
----> 4 from .defmatrix import *
5
6 __all__ = defmatrix.__all__
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\matrixlib\defmatrix.py in <module>
9 # While not in __all__, matrix_power used to be defined here, so we import
10 # it for backward compatibility.
---> 11 from numpy.linalg import matrix_power
12
13
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\linalg\__init__.py in <module>
71 """
72 # To get sub-modules
---> 73 from .linalg import *
74
75 from numpy._pytesttester import PytestTester
C:\Anaconda3\envs\my-env\lib\site-packages\numpy\linalg\linalg.py in <module>
31 from numpy.core import overrides
32 from numpy.lib.twodim_base import triu, eye
---> 33 from numpy.linalg import lapack_lite, _umath_linalg
34
35
ImportError: DLL load failed: The specified module could not be found.
Could someone advise me on what might be the issue? If it helps, my (base) environment has a python version of 3.8.3 and a notebook version of 6.0.3, whereas my new my-env environment has modules downloaded from conda-forge. It has a python version of 3.7.8 and an ipykernel version of 5.3.4.
Thanks in advance!
UPDATE 26 Oct 2020
As requested, I have included the list of modules I have in both the (base) environment and the (my-env) environment. In general, the packages in (base) have been kept updated with respect to the anaconda module, whereas the packages in (my-env) are kept up-to-date with respect to hyperspy, which is stored in the conda-forge repository.
I have created PasteBin entries for them, as they exceed the character limit for this post.
Link to list of modules in (base)
Link to list of modules in (my-env)
I also tried importing modules other than matplotlib and numpy, and was able to import abc and time without issue, for example. This seems to be an issue with the (base) version of Jupyter Notebook not being compatible with the numpy found in the (my-env) environment.
The error message is indicating the error is arising from the numpy library. The fact that your Python and Ipkernel versions are different between your (base) and your (my-env) is further indication that there is incompatibility between your environments.
Can you provide the output from
conda list
from each environment?
When I tried to create a Python=3.8.3 environment the numpy version installed is numpy-1.19.2-py38hf89b668_1
I used the command
conda create -n foo -c conda-forge python=3.8.3 numpy
When I tried to create a Python=3.7.8 environment the numpy version installed is numpy-1.19.2-py37h7008fea_1
I used the command
conda create -n foo -c conda-forge python=3.7.8 numpy
In addition, why don't you consider installing ipkernel / jupyter notebook libraries that are consistent with respective versions of Python in each environment? This would always be the best solution to ensure dependencies are correctly aligned.
I also attempted to install ipykernel in both python=3.8.3 and python=3.7.8 along with ipykernel without specifying version number.
Here are the versions of ipykernel that condaautomatically chooses:
for python=3.8.3: ipykernel-5.3.4 | py38h1cdfbd6_1
for python=3.7.8: ipykernel-5.3.4 | py37hc6149b9_1
From what you have written your ipykernel versions are different. I do think this discrepancy is most likely coming from these differences of ipykernel versions
When you check your environments, verify that the channel source for ipykernel is the same.
One Solution: Consider downgrading the ipykernel in (base) to 5.3.4 version.
I'm trying to import tensorflow. But even after installing it, it doesn't seem to be recognized.
>conda create -n tf tensorflow
>conda activate tf
(tf)>pip install --ignore-installed --upgrade tensorflow==1.15 --user
...
Successfully installed absl-py-0.9.0 astor-0.8.1 gast-0.2.2 google-pasta-0.2.0 grpcio-1.28.1 h5py-2.10.0 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.2.1 numpy-1.18.2 opt-einsum-3.2.0 protobuf-3.11.3 setuptools-46.1.3 six-1.14.0 tensorboard-1.15.0 tensorflow-1.15.0 tensorflow-estimator-1.15.1 termcolor-1.1.0 werkzeug-1.0.1 wheel-0.34.2 wrapt-1.12.1
(tf) C:\Users\antoi\Documents\Programming\Covent Garden\covent_garden_ds>python3 app.py
Traceback (most recent call last):
File "app.py", line 4, in <module>
from tensorflow.keras.callbacks import ModelCheckpoint
ModuleNotFoundError: No module named 'tensorflow'
Python3 is there:
(tf) C:\Users\antoi\Documents\Programming\Covent Garden\covent_garden_ds>where python3
C:\Users\antoi\AppData\Local\Microsoft\WindowsApps\python3.exe
It's not the one I should be using, isn't it?
What version of Python are you running? In order to both successfully import and run the Tensorflow module, you must have the 64 bit version of Python installed. If you are using the latest version of Python, which to the best of my knowledge is 3.8.2, completely uninstall that version of Python, and downgrade to the latest Python version with 64 bit support.
If you follow the output of pip --version to find where your anaconda files are located, you can find the anaconda python executable, usually about two directory levels higher (if pip is in C:\example\anaconda\lib\site-packages, then python is probably in C:\example\anaconda) and use a full path to that python executable to run the file like C:\example\anaconda\python app.py. Or you could update your path environment variable to replace C:\Users\antoi\AppData\Local\Microsoft\WindowsApps\ with the directory containing the anaconda python executable
I've had this same exact issue (but on macOS) several times before I realized what was wrong, and I've seen several others have this issue too. I wish there was a way Python could somehow better regulate this to make sure the default executables for pip and python are always in sync
I'm trying to install fbprophet on my win10 64 bit machine (anaconda). I've followed the instructions here here and here, but I keep getting the same error:
ImportError Traceback (most recent call last)
<ipython-input-1-7dd3504c366f> in <module>
----> 1 import pandas as pd
~\Anaconda3\envs\fbprophet\lib\site-packages\pandas\__init__.py in <module>
15 if missing_dependencies:
16 raise ImportError(
---> 17 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
18 )
19 del hard_dependencies, dependency, missing_dependencies
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\Users\Ran\Anaconda3\envs\fbprophet\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.0" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
I assume it has something regarding the numpy version, but the version in the virtual environment I've created for fbprophet is as required (1.17). It seems that this evnironment tries to use different version of numpy.
I have numpy installed in my anaconda base and in other virtual environments and there is nothing wrong with it. It happens only when I try to install fbprophet.
UPDATE:
I was able to solve the problem by uninstall numpy (v 1.17) and install instead numpy v1.16
When I try to run
import sklearn.linear_model
I get an error
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone1\lib\site-packages\sklearn\linear_model\least_angle.py in <module>
21 from .base import LinearModel
22 from ..base import RegressorMixin
---> 23 from ..utils import arrayfuncs, as_float_array, check_X_y, deprecated
24 from ..model_selection import check_cv
25 from ..exceptions import ConvergenceWarning
ImportError: DLL load failed: The specified module could not be found.
I did some digging, and it looks like I don't have the as_float_array package
ModuleNotFoundError: No module named 'sklearn.utils.as_float_array'
I tried reinstalling, but no change. What's going on?
This appears to be very specific to your IDE/environment. It will be easier to solve if you provide more details. You can try the following:
Are you able to run the following code?
import sklearn
print(sklearn.__version__)
Can you list the packages installed and see if sklearn is there?
pip3 list
Do you see the same problem in Anaconda alone, or when you run this in command line?
Edit: possible solution
This looks like an access issue.
If you are on Windows OS, remove Anaconda & re-install it in a common folder, instead of under admin controlled folders (for example C:\anaconda, instead of under C:\Program Files).
Launch a new terminal from Anaconda Navigator -> Environments, then run this code.
Usually a conda install solves the problem:
conda install -c anaconda scikit-learn
It happened to me, for numpy
Previously ROS was installed in my system which requires opencv for its implementation and now I am using anaconda in which I need to use the opencv library once again. While writing python code import cv2 throws an error module not found.
Is there any way to use that opencv library which ROS installed in anaconda
Although I installed opencv once again using conda.
$conda install -c conda-forge opencv
however opencv-3.3 was installed using above command. Now my python code is showing different import error as shown below:
ImportError Traceback (most recent call last)
<ipython-input-9-6b49ad4d4ca5> in <module>()
1 from random import shuffle
2 import glob
----> 3 import cv2
4 shuffle_data = True # shuffle the addresses before saving
5 hdf5_path = 'dataset.hdf5' # address to where you want to save the hdf5 file
ImportError: /home/kamal/ros_catkin_ws/install_isolated/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
How can I particularly specify which opencv library to use. What env variables I need to change.
Any help will be appreciated.
uncommenting the line source /home/user/ros_catkin_ws/install_isolated/share/setup.bash in the .bashrc file dosen't help. You also need to remove the extrasys.path added by the ROS environment.
In a python console
import sys
print (sys.path)
you will see multiple paths related to ROS
then remove the unwanted part of the path by
sys.path.remove('unwanted_path')
This will solve the problem but now ROS will not work. To make it work you need to append the removed path again.
If someone has a better approach please answer.