OS:Ubuntu 18.04 LTS
Python Environment = 3.6.8 (System default version)
I followed this link to install cocoapi.
However, it shows the error below:
ubuntu:~/cocoapi-master/PythonAPI$ make
python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 2, in <module>
import numpy as np
ImportError: No module named numpy
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1
I have already installed the needed dependencies mentioned in objection_detection/g3doc/installation.md.
I have also installed Cython and Numpy.
Could somebody help me fix this issue? Thanks in advance.
I run this code
python3 setup.py build_ext --inplace
It doesn't show error.
However, when I tried to run a Tensorflow/models/research/object_detection/model_main.py, it shows error again.
Command line:
ubuntu:~/PycharmProjects/PedestrianDetection$ python object_detection/model_main.py --pipeline_config_path=pretrained/pipeline.config --model_dir=train --num_train_steps=1000 --sample_1_of_n_eval_examples=1 --alsologtostderr
Error:
Traceback (most recent call last):
File "object_detection/model_main.py", line 26, in <module>
from object_detection import model_lib
File "/home/yantong/PycharmProjects/PedestrianDetection/object_detection/model_lib.py", line 28, in <module>
from object_detection import eval_util
File "/home/yantong/PycharmProjects/PedestrianDetection/object_detection/eval_util.py", line 28, in <module>
from object_detection.metrics import coco_evaluation
File "/home/yantong/PycharmProjects/PedestrianDetection/object_detection/metrics/coco_evaluation.py", line 20, in <module>
from object_detection.metrics import coco_tools
File "/home/yantong/PycharmProjects/PedestrianDetection/object_detection/metrics/coco_tools.py", line 47, in <module>
from pycocotools import coco
File "/home/yantong/PycharmProjects/PedestrianDetection/pycocotools/coco.py", line 55, in <module>
from . import mask as maskUtils
File "/home/yantong/PycharmProjects/PedestrianDetection/pycocotools/mask.py", line 3, in <module>
import pycocotools._mask as _mask
ModuleNotFoundError: No module named 'pycocotools._mask'
Under ~/PycharmProjects/PedestrianDetection/pycocotools, I have
cocoeval.py coco.py __init__.py mask.py __pycache__
cocoeval.py.bak coco.py.bak _mask.c _mask.pyx
I'm wondering why it shows No module named 'pycocotools._mask' as well.
According to #Joe A 's guidance, finally make pycocotools by prompting:
pip3 install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
It will be installed in the Ubuntu path /home/USERNAME/.local/lib/python3.6/site-packages
Enter the path /home/USERNAME/.local/lib/python3.6/site-packages
Using Terminal to cd the path above.
NOTICE: USERNAME means your account name on Ubuntu (for me is yantong), replace it with yours.
Copy the downloaded pycocotools from the Step1-2 to your code package.
cp -r pycocotools YOUR_PACKAGE_PATH
NOTICE: You'd better replace YOUR_PACKAGE_PATH with your package's absolute path.
Test
Test by open a Python3 script and prompt:
from pycocotools.coco import COCO
from pycocotools import mask as maskUtils
Press ENTER, if not with error, congrats!
The problem might be the gcc version or installations in your system, follow this if the above solutions fail.
here's how I did it successfully! (the reason is the gcc version)
install the dependencies: cython (pip install python), opencv (pip install opencv-python)
check the gcc version by this command: gcc --version
your output will be like this 'Command 'gcc' not found, but can be installed with:
sudo apt install gcc
'
Type the below commands to install the gcc:
sudo apt update
sudo apt install build-essential
sudo apt-get install manpages-dev
now check again the gcc version(step2)
if you get below output
'gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
now run the code for pycocotools installations:
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
finally wait to check if the installation is successful :
'Successfully installed pycocotools-2.0'
Related
I have already seen https://bugs.python.org/issue34036 but it did not help.
I am trying to instal python using the followin command
pyenv install 3.7.0
But it throws the following error
If the version you need is missing, try upgrading pyenv:
Downloading Python-3.7.0.tar.xz...
-> https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz Installing Python-3.7.0...
BUILD FAILED (Ubuntu 16.04 using python-build 20180424)
Inspect or clean up the working tree at
/tmp/python-build.20181018113151.14218 Results logged to
/tmp/python-build.20181018113151.14218.log
Last 10 log lines: File
"/tmp/tmpecnjnct9/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/init.py",
line 42, in
File
"/tmp/tmpecnjnct9/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/cmdoptions.py",
line 16, in
File
"/tmp/tmpecnjnct9/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/index.py",
line 25, in
File
"/tmp/tmpecnjnct9/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/download.py",
line 39, in
File
"/tmp/tmpecnjnct9/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/utils/glibc.py",
line 3, in
File
"/tmp/python-build.20181018113151.14218/Python-3.7.0/Lib/ctypes/init.py",
line 7, in
from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'
Makefile:1122: recipe for target 'install' failed
make: *** [install] Error 1
Install the libffi development package:
sudo apt-get install libffi-dev
and try again.
I have an error when running app with python3.5
Traceback (most recent call last):
File "/usr/local/bin/face_recognition", line 7, in <module>
from face_recognition.cli import main
File "/usr/local/lib/python3.5/site-packages/face_recognition/__init__.py", line 7, in <module>
from .api import load_image_file, face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/site-packages/face_recognition/api.py", line 4, in <module>
import dlib
File "/usr/local/lib/python3.5/site-packages/dlib/__init__.py", line 1, in <module>
from .dlib import *
ImportError: /usr/local/lib/python3.5/site-packages/dlib/dlib.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE
I can see that libboost is the problem, I compiled it with appropriate version of python and set python root as well but still have an error. What did I miss?
I also meet this kind of problem. On my Mac, I have installed a version of boost 1.58 from source code.
When I try to install dlib by following command:
brew install cmake
brew install boost
brew install boost-python --with-python3
sudo pip3 install numpy
sudo pip3 install scipy
sudo pip3 install scikit-image
sudo pip3 install dlib
I think dlib use the wrong version of boost on my Mac.
Here is my solution:
try to delete boost using brew uninstall, and delete all related boost include and lib files from /usr/local/include & /usr/local/lib.
reinstall above brew & pip3 commands to reinstall all related libraries.
After this two steps, my Mac now can use dlib under Python3 correctly.
I am absolutely new to python and tried to install Theano.
Therefore I ran $ pip install numpy scipy.
Pip seems up to date but I always get the same error:
Collecting scripy
Using cached Scripy-0.9.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/setup.py", line 96, in <module>
description=get_description(packages[0], PACKAGE_DIR),
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/setup.py", line 47, in get_description
pkg = __import__(package, level=1)
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/lib/scripy/__init__.py", line 11, in <module>
from .edit import *
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/lib/scripy/edit.py", line 18, in <module>
import yamlog
ImportError: No module named yamlog
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/
What am I doing wrong?
Thanks a lot!
No, you must have typed:
pip install numpy scripy # <-- should be `scipy`
You can see clearly from the output it is attempting to install scripy not scipy. Whatever this scripy pip package is, it clearly doesn't define its dependencies properly.
You didn't specify distribution and version but if you have python 2.7 I guess this might work.
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git
sudo pip install Theano
I am trying to install ruamel.yaml python library in a Centos 7 machine where I don't have internet connection. I tried this:
installed libyaml-devel, python-devel, python-pip using a local repository
downloaded ruamel.yaml-0.13.14.tar & ruamel.ordereddict-0.4.6.tar(dependency) from pypi.
now I am able to install ruamel.ordereddict using pip install .,
but when I tried to install ruamel.yaml in the same way, I got the following exception:
[root#limulus ruamel.yaml-0.13.14]# pip install .
Processing /tmp/python/ruamel.yaml-0.13.14
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 7, in <module>
from setuptools.command.install import install
File "/usr/lib/python2.7/site-packages/setuptools/command/__init__.py", line 8, in <module>
from setuptools.command import install_scripts
File "/usr/lib/python2.7/site-packages/setuptools/command/install_scripts.py", line 3, in <module>
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 74, in <module>
import parser
File "parser.py", line 77, in <module>
from ruamel.yaml.error import MarkedYAMLError # type: ignore
File "/usr/lib64/python2.7/site-packages/ruamel/__init__.py", line 5, in <module>
__import__('pkg_resources').declare_namespace(__name__)
AttributeError: 'module' object has no attribute 'declare_namespace'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-oOWX1x-build/
What is the correct way of installing a python library in offline mode?
It looks like you have been expanding the tar files, which is not necessary, but I am not sure if that is the reason why you get this error, you probably are also missing the typing dependency.
What you shouldn't do is use the system installed pip, it is almost out of date and on some systems actually causes problems because of unfixed bugs in those old versions.
What you also should not do is install packages using pip outside of a Python virtualenv, as this might break your system when it updates/overwrites things in the systems site-packages/dist-packages directory. The solution provided below only installs pip/wheels/virtualenv in the system directory, that is AFAIK safe, but there are ways around that as well if it would necessary.
You should also consider using the provided wheels to install packages. That way C extension don't need compilation.
On a machine that is online do:
mkdir /tmp/offline
cd /tmp/offline
# your python-pip installed pip might not support wheels
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
wget https://pypi.python.org/packages/a7/37/947b4329c4a3c72093b6c8e9b4be8c7f10c32dbb78848d3a234ce01c059d/wheel-0.30.0a0.tar.gz
wget https://pypi.python.org/packages/6f/86/3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/virtualenv-15.1.0-py2.py3-none-any.whl
Now download the required wheels (.tar.gz if not available):
wget https://pypi.python.org/packages/96/4b/5251bf469f37e49e0c92f841b5b3ef01a1c9d652cc018df470e5ae235eb8/ruamel.ordereddict-0.4.9-cp27-cp27mu-manylinux1_x86_64.whl
wget https://pypi.python.org/packages/63/40/c38b857ec6a083e534ee9a9f655741120d4bfd9139232681f976cf44272b/ruamel.yaml-0.13.14-cp27-cp27mu-manylinux1_x86_64.whl
wget https://pypi.python.org/packages/b6/0c/53c42edca789378b8c05a5496e689f44e5dd82bc6861d1ae5a926ee51b84/typing-3.5.3.0.tar.gz
Copy the six files to a new directory your offline system, and there do
sudo pip install pip*.tar.gz wheel*.tar.gz
sudo pip install virtualenv*
virtualenv ~/ruamel
source ~/ruamel/bin/activate
pip install typing* ruamel*
That gives you a virtualenv with ruamel.yaml installed, just add your application in there as well.
The downloads used here are current as of 2017-01-07, you can get more up-to-date ones using your browser (on the on-line system) if necessary.
I'm completely new to programming. I've been trying various ways to install NLTK on my Mac (running OS 10.5.8), and none of them is working. Please help! Here's what I've done so far.
Since at first I didn't realize that newer versions of Python required OS 10.6 or higher, I first tried to install the latest versions of both Python 3 and Python 2, but this obviously didn't work. I then cottoned on and found an older installation (the filename is python-2.7.6-macosx10.3.dmg), which installed successfully.
I then tried to follow the instructions on this page, which I copy below:
Install Setuptools: http://pypi.python.org/pypi/setuptools
Install Pip: run sudo easy_install pip
Install Numpy (optional): run sudo pip install -U numpy
Install PyYAML and NLTK: run sudo pip install -U pyyaml nltk
Test installation: run python then type import nltk
Steps 1 and 2 worked fine, but when I try steps 3 and 4, I get an error. The error is the same whether I try step 3 or step 4:
unknown0021E9E0E476:~ Tom$ sudo pip install -U numpy
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module> load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1906, in loadentry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/util.py", line 17, in <module>
from pip.vendor.distlib import version
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/version.py", line 13, in <module>
from .compat import string_types
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/compat.py", line 276
return b''
^
SyntaxError: invalid syntax
I then found a different set of instructions on this page. It first has you install Xcode and MacPorts, which I did (again finding older versions compatible with 10.5.8). I got through the next few steps successfully: installed python27, made it the system default (sudo port select --set python python27), and installed the dependencies py27-numpy, py27-yaml, and py27-scipy. However, I can't install one needed package, py27-matplotlib. Here's what happens when I try:
unknown0021E9E0E476:~ Tom$ sudo port install py27-matplotlib
---> Computing dependencies for py27-matplotlib
---> Dependencies to be installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
---> Staging py27-pyobjc into destroot
Error: org.macports.destroot for port py27-pyobjc returned: command execution failed
Error: Failed to install py27-pyobjc
Please see the log file for port py27-pyobjc for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-pyobjc/py27-pyobjc/main.log
Error: The following dependencies were not installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py27-matplotlib failed
Without this package, I can't go on to install NLTK.
I've also tried installing NLTK in PyCharm, but that didn't work either: see this question. I'm at my wits' end here, so any help would be much appreciated!
ETA: Problem solved! I downloaded the tar.gz file from https://pypi.python.org/pypi/nltk and followed the install instructions in the package, and now I can import NLTK in the Python shell. Is it possible that I was simply trying to install things while in the wrong directory? (I'd still like to use NLTK in PyCharm, so answers to that question will still be welcome.)
Try installing the scipy package which includes matplotlib and numpy, I was a TA on a course where we used numpy and matplotlib quite a lot and using the scipy package to install was a solution for a lot of people.
The individual binary and source packages are available from: scipy docs
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose