ImportError: cannot import name 'label_map_util' - python-3.6

I'm running on Python 3.6.5 (64bits) trying to run the object_detection_tutorial.
I receive this message when I run the programm :
ImportError: cannot import name 'label_map_util'
Any idea on what I should do ?
Edit : I tried to see whether or not I installed the API and got this :
C:\tensorflow\models-master>python object_detection/protos/label_map_util_test.py
python: can't open file 'object_detection/protos/label_map_util_test.py': [Errno 2] No such file or directory

Try this instead...
from object_detection.utils import label_map_util

Get current dir :
os.getcwd()
change current dir :
os.chdir( '../models/research/object_detection' )
CD to object_detection directory
And you can replace
from utils import label_map_util to
from object_detection.utils import label_map_util
and
from utils import visualization_utils as vis_util to
from object_detection.utils import visualization_utils as vis_util

Related

ImportError: cannot import name 'pytext_config_from_json' from 'pytext.config.serialize'

I'm trying to fine-tune XLM-R model by following this colab notebook.
While running the following cell in kaggle notebook
from pytext.config.serialize import pytext_config_from_json
I'm getting the error
ImportError: cannot import name 'pytext_config_from_json' from 'pytext.config.serialize' (/opt/conda/lib/python3.7/site-packages/pytext/config/serialize.py)
I have installed pytext by
!pip install --quiet git+https://github.com/facebookresearch/pytext
Thanks
Try
from pytext.config import pytext_config_from_json

Not able to import simpletransformers.ner in python as it says ImportError: cannot import name 'BertweetTokenizer'

I am trying to do bert based NER and trying to import,
from simpletransformers.ner import NERModel, NERArgs
I have installed simpletranformers in pip and when I try to import,
import simpletransformers.ner
it says, ImportError: cannot import name 'BertweetTokenizer'. When I try to install BertweetTokenizer, it throws
ERROR: No matching distribution found for BertweetTokenizer
Not sure, what I am missing. Kindly help

py2app: Compiles app but app has error on opening

I am working on a Python application in Python3.6 that I would like to convert into a standalone application that can be ported easily to other devices. I tried using py2app as in this tutorial.
Everything works well until I get to the point of actually creating the app. It does not throw any error in the creation process and creates the .app file, however, when I try to run it, A window pops up saying there is an error and gives me the options of terminating or opening the console. I tried opening the console but I cannot find any substantive information in the error messages.
These are the import statements that I have:
from urllib.request import urlopen, build_opener
from bs4 import BeautifulSoup, SoupStrainer
import ssl
import urllib
import sys
import subprocess
from tkinter import *
from tkinter.ttk import *
import webbrowser
from unidecode import unidecode
As far as I know the only 2 packages that aren't standard with python are bs4 and unidecode. My setup.py file looks like this:
from setuptools import setup
APP = ['GUImain.py']
DATA_FILES = ['logo.png']
OPTIONS = {'argv_emulation': True,
'iconfile': 'logo.png',
'includes': ['undidecode','bs4']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
I haven't seen any other errors like this one from any of my searching. I have seen some suggestion that py2app doesn't fully support Python3.6. Does anyone know how I can figure out what error is being thrown? Any suggestions on different tools to use and tutorials on how to use them?

Error in importing a new python module in knitr

I want to use a python engine in knitr. I have installed a module named undaqTools for python 2.7 using Anaconda3. If I run the following in IPython, it works fine:
from undaqTools import Daq
I tried the same in a python code chunk but that didn't work. I found a relevant question in SO, linked here. So, I first did following in IPython:
import undaqTools
import os
path = os.path.dirname(undaqTools.__file__)
path
Out[5]: 'C:\\Anaconda3\\envs\\py27\\lib\\site-packages\\undaqtools-0.2.3-py2.7.egg\\undaqTools'
Therefore, I created a new chunk in knitr and did following:
```{python}
import sys
sys.path.append('C:/Anaconda3/envs/py27/lib/site-packages/undaqtools-0.2.3-py2.7.egg/')
from undaqTools import Daq
```
But that gives me following error:
Traceback (most recent call last):
File "C:\Users\durraniu\AppData\Local\Temp\RtmpGOOQHX\chunk-code195061e728da.", line 13, in <module>
from undaqTools import Daq
File "C:\Anaconda3\envs\py27\lib\site-packages\undaqtools-0.2.3-py2.7.egg\undaqTools\__init__.py", line 5, in <module>
ImportError: No module named 'daq'
How can I fix this?

cx_Freeze on complex python program

I'm trying to create an executable out of a file that I have made with python. I got cx_Freeze to work, but once I try to open the exe file, it will say that "there is no module named ..." I am trying to make an executable out of a program that starts with:
import serial
import time
import re
import tkinter
import math
from scipy.interpolate import interp1d
import numpy as np
import os
My setup.py file currently looks like this:
import cx_Freeze
import sys
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("SerialComsCombined.py", base=base)]
cx_Freeze.setup(
name = "4DCT_Client",
options = {"build_exe": {"packages":["tkinter"]}},
version = "0.01",
description = "Serial Coms Combined",
executables = executables
)
I feel like the setup.py file needs to be modified. Any suggestions?

Resources