Installing tensorflow object_detection api in a repo in google drive - python-3.x

I have cloned the models repo from TensorFlow and installed it into my project folder in google drive.
but when I try to run the model_builder_tf2_test.py I am getting ModuleNotFoundError: No module named 'object_detection' error.
import sys
nb_path = '/content/drive/MyDrive/project/lib'
sys.path.insert(0, nb_path)
and installed it using the following command
!python -m pip install --target=$nb_path .
the files are downloaded into the project folder but can't be accessed by the files in models repo.
however, I can access the modules using the:
import sys
sys.path.append('/content/drive/MyDrive/project/lib')
The error I am getting after running:
%cd /content/drive/MyDrive/project/models/research
!python object_detection/builders/model_builder_tf2_test.py
is:
Traceback (most recent call last):
File "object_detection/builders/model_builder_tf2_test.py", line 24, in <module>
from object_detection.builders import model_builder
ModuleNotFoundError: No module named 'object_detection'

I would add this as a comment but still don't have enough reputation.
did you try using this?
pip install tensorflow-object-detection-api
if it helps,
believe the question is a duplicate?

Related

64bit MacOs After succesfully installing Pygame: ModuleNotFoundError: No module named 'pygame'

Python noob here. I've been trying to install pygame and pandas for a few hours now. Even with Conda I did not succeed. I have Python 3.8.5 installed.
I eventually tried through the terminal with these commands:
python -m pip install pygame==2.0.0.dev6
and
python -m pip install pandas
(this was a total guess by the way, but apparently it did something)
Results were succesfull:
Requirement already satisfied: pygame==2.0.0.dev6 in /opt/miniconda3/lib/python3.8/site-packages (2.0.0.dev6)
and
Successfully installed numpy-1.19.2 pandas-1.1.2 python-dateutil-2.8.1 pytz-2020.1
But, when I try to import either modules, I still get errors. Any ideas?
import pygame
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
import pandas
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Do I need to move the modules to the script folder or something? Or what do I even move? Thanks!
Ok.. Got it thanks to #matt.. after succesfully installing pygame, find the environment in which pygame is installed by entering 'which python'.
In my case it returned:
/opt/miniconda3/bin/python
Now I needed to make sure the VS console was pointing at the same environment, by checking which python interpreter it was using and selecting the correct one. More info:
how to check and change environment in VS Code

ImportError: cannot import name 'Coroutine'

I am trying to follow this instructions here:
https://github.com/hyperledger/indy-agent/blob/master/python/README.md
in order to simulate Hyperledger indy interactions, on a ubuntu 18.04 AWS instance.
I already cloned the repository and installed dependencies.(I am following dev mode instruction because the docker fails)
Then i launch the command:
python3 indy-agent.py 8094
And here the logs I have:
Traceback (most recent call last):
File "indy-agent.py", line 17, in <module>
import aiohttp_jinja2
File "/home/ubuntu/.local/lib/python3.5/site-packages/aiohttp_jinja2/__init__.py", line 6, in <module>
from aiohttp import web
File "/home/ubuntu/.local/lib/python3.5/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import (
File "/home/ubuntu/.local/lib/python3.5/site-packages/aiohttp/client.py", line 12, in <module>
from typing import ( # noqa
ImportError: cannot import name 'Coroutine'
This the aiohttp/client.py file:
"""HTTP Client for asyncio."""
import asyncio
import base64
import hashlib
import json
import os
import sys
import traceback
import warnings
from types import SimpleNamespace, TracebackType
from typing import ( # noqa
Any,
Coroutine,
Generator,
Generic,
….
)
This is the aiohttp/init.py file:
version = '3.5.4'
from typing import Tuple # noqa
from . import hdrs
from .client import (
….
And this is the aiohttp_jinja2/init.py:
import asyncio
import functools
import warnings
import jinja2
from collections import Mapping
from aiohttp import web
….
Any ideas on how to fix it?
Should I change some lines of code in one of these files?
Thanks
ADDITIONAL INFORMATION(BASED ON ANSWERS)
After the feedback from the answers, I updated to python 3.6.9.
While the asyncio problems fixed, still I get problems While setting up docker in the /python directory, I got the following:
1)make docker-build
2)sudo make docker-start PORT=8094
docker run -it -p $PORT:$PORT -e PORT=$PORT --name indy-agent_$PORT indy-agent
Traceback (most recent call last):
File "indy-agent.py", line 20, in <module>
from modules.connection import Connection, AdminConnection
File "/app/modules/__init__.py", line 1, in <module>
from python_agent_utils.messages.errors import ValidationException
ModuleNotFoundError: No module named 'python_agent_utils'
Makefile:5: recipe for target 'docker-start' failed
make: [docker-start] Error 1 (ignored)
docker rm indy-agent_$PORT
indy-agent_8094
When I try to install manually(without docker), I try to launch “pip install -r requirements.txt”, and I get the following:
ERROR: Could not find a version that satisfies the requirement aiohttp==3.5.4 …….ERROR: No matching distribution found for aiohttp==3.5.4 (from -r requirements.txt (line 2))
Then, when I try to launch the command “python3.6 indy-agent.py 8094”, I get continuously logs about missing modules. I installed them manually, which allowed me to go a little further in the process. But then I receive logs about modules that I cannot install through python.
This fact of having to install all the modules manually seems very strange to me, but I installed the agent outside the indy-sdk directory and also inside indy-sdk directory, and I get the same results.
Here’s the commands I launch and the logs I get:
1)python3.6 indy-agent.py 8094
ModuleNotFoundError: No module named 'aiohttp_jinja2'
2)python3.6 -m pip install aiohttp_jinja2
3)python3.6 indy-agent.py 8094
ModuleNotFoundError: No module named 'base58'
4)python3.6 -m pip install base58
No module named 'dateutil'
5)python3.6 -m pip install python-dateutil
6)python3.6 indy-agent.py 8094
ModuleNotFoundError: No module named 'indy'
7)sudo apt-get update
8)sudo apt-get install -y libindy
9)python3.6 -m pip install indy
10)python3.6 indy-agent.py 8094
ImportError: cannot import name 'did'
11)python -m pip install did
12)sudo python3 -m pip install did
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Could not find a version that satisfies the requirement did (from versions: )
No matching distribution found for did

DLL load failed for pytables

I get the following error when running code containing pytables:
Traceback (most recent call last):
File "C:\Users\pierr\python354\lib\site-packages\pandas\io\pytables.py", line 469, in __init__
import tables # noqa
File "C:\Users\pierr\python354\lib\site-packages\tables\__init__.py", line 90, in <module>
from .utilsextension import (
ImportError: DLL load failed: The specified procedure could not be found.
...
File "C:\Users\pierr\python354\lib\site-packages\pandas\io\pytables.py", line 472, in __init__
'importing'.format(ex=str(ex)))
ImportError: HDFStore requires PyTables, "DLL load failed: The specified procedure could not be found." problem importing
python version 3.5.4 |
tables version 3.4.2 | windows 10
I had a similar problem. When I tried to run the following code:
import pandas as pd
df = pd.read_hdf('some.hdf')
I got an error:
ImportError: Missing optional dependency 'tables'. Use pip or conda to install tables.
Even though the pytables module was installed using both conda and pip (with last, of course as tables), the error still persisted.
The import tables didn't work either:
from .utilsextension import (
ImportError: DLL load failed: Не найден указанный модуль.
"Не найден указанный модуль" means "The specified module was not found" in Russian.
I climbed into the folder where the last module from the Traceback is located - '~\AppData\Roaming\Python\Lib\site-packages\tables' and found file named utilsextension.cp37-win_amd64.pyd there. Then I downloaded Dependency Walker utility and looked at this file. The program said it couldn't find pytables_hdf5.dll. I found this file in the folder ~\AppData\Roaming\Python\Lib\site-packages\tables\ and added it to a PATH variable by:
os.environ['PATH'] += os.pathsep + os.path.expanduser('~\\AppData\\Roaming\\Python\\Lib\\site-packages\\tables')
After that everything worked, import tables and pd.read_hdf return no more errors.
Hope this is useful to someone.
Installing PyTables using these installation instructions helped me to resolve this issue. I used Conda option.
I had the same problem. It went away after I uninstalled and reinstalled pytables.
conda remove -n MYENVNAME pytables
conda config --add channels conda-forge
conda install pytables

How to get python API to access Smartsheet

I am following the smartsheet API's python-sdk example to do some practice.
Below are my steps (using Python 3.4.4 on macOS 10.7.5):
installed the SDK package from their GitHub repo
installed pip using pip install smartsheet-python-sdk in my terminal
created a .py file and moved it into the SDK file
Issue
When I run it, I got following error message:
Traceback (most recent call last):
File "/Users/canny_aiyaya/Desktop/smartsheet-python-sdk-master/smartsheet/charity.py", line 5, in <module>
import smartsheet
File "/Users/canny_aiyaya/Desktop/smartsheet-python-sdk-master/smartsheet/smartsheet.py", line 28, in <module>
import requests
ImportError: No module named 'requests'
Code in the .py file
import smartsheet
ss_client = smartsheet.Smartsheet(access_token)
ss_client.errors_as_exceptions(True)
Analysis
I looked for some possible solutions, and try to install requests on my terminal using sudo pip3 install requests, but it shows:
No matching distribution found for requests
This is my first time trying to use API on Smartsheet, any supports/links/videos will very helpful.
There are a number of dependencies. You can run python setup.py install from the Smartsheet SDK directory to install them.

Tensorflow Object Detection API / ImportError: cannot import name 'keypoint_box_coder_pb2'

I followed instructions (https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md) to install the Tensorflow Object Detection
API. I use Anaconda on Windows 10 and all of the steps in the instructions seemed to complete OK.
But when trying to run python object_detection/builders/model_builder_test.py to test the installation, I get: ImportError: cannot import name 'keypoint_box_coder_pb2'
What am I missing?
(tensorflow) C:\Users\User\Documents\GitHub\models\research>python
object_detection/builders/model_builder_test.py Traceback (most recent
call last): File "object_detection/builders/model_builder_test.py",
line 21, in
from object_detection.builders import model_builder File "C:\Users\User\New\Anaconda3\envs\tensorflow\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\builders\model_builder.py",
line 18, in
from object_detection.builders import box_coder_builder File "C:\Users\User\New\Anaconda3\envs\tensorflow\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\builders\box_coder_builder.py",
line 21, in
from object_detection.protos import box_coder_pb2 File "C:\Users\User\New\Anaconda3\envs\tensorflow\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\protos\box_coder_pb2.py",
line 17, in ImportError: cannot import name
'keypoint_box_coder_pb2'
I got it to work. What I did was:
I ran:
protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto
What was missing was: .\object_detection\protos\keypoint_box_coder.proto
Then ran:
python setup.py build
python setup.py install
Then changed:
nets to research.slim.net in faster_rcnn_inception_resnet_v2_feature_extractor.py and faster_rcnn_resnet_v1_feature_extractor.py (in the models folder)
Ran:
python object_detection/builders/model_builder_test.py
Got:
Ran 11 tests in 0.195s
OK
It looks like you have not run
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim # (from tensorflow/models/research folder)
in the same terminal before launching the test, have you ? If you've chosen the .bashrc option, you probably need to reload your bshrc filewith . ~/.bashrc

Resources