Tag Archives: python

Tensorflow operation report error modulenotfounderror: no module named ‘tensorflow. Python. Types’ solution

Running with tensorflow 1.15, the following error occurs:,

terms of settlement:

It is found that the tensorflow estimator installed automatically when installing 1.15.0 is version 2.5.0 (Figure 2)

Uninstall version 2.5: PIP uninstall   tensorflow-estimator

Reinstall version 1.15: CONDA install    tensorflow-estimator==1.15.1   Or pip   install    Tensorflow estimator = = 1.15.1 (I installed it with Canda, but failed to use pip, prompting an error, valueerror: check_ hostname requires server_ Hostname, after searching this error, I need to close the agent, but I rely on the agent to connect to the network but not close…)

Problem solving.

Note: the reason for installing 1.15.1 is that version 1.15.0 is not found. If you want to download the manual installation from the official website, you can only find tensorflow CPU estimator 1.15.1, search results · pypi

  Reference: modulenotfounderror: no module named ‘tensorflow. Python. Types’ – stack overflow

ParserError: Error tokenizing data. C error: EOF inside string starting at row 917

Solution:

Add when reading files   quoting=csv.QUOTE_ NONE

  data = pd.read_ csv(path + ‘/’ + fn,quoting=csv.QUOTE_ NONE)

Quote mode is no reference. When reading, it is considered that the content is not surrounded by the default reference character (“).

Relevant knowledge points:

pandas.read_ CSV parameters

quoting  : int or csv.QUOTE_* instance, default 0

Controls quotation mark constants in CSV.

Optional quote_ MINIMAL (0), QUOTE_ ALL (1), QUOTE_ NONNUMERIC (2) ,QUOTE_ NONE (3)

Other similar errors

1、pandas.errors.ParserError: Error tokenizing data. C error: Expected * fields in line *, saw *

solve:

Method A. add parameters when reading files     error_ bad_ Lines = false # add parameters

data= pd.read_ csv(data_ file,   error_ bad_ lines=False)

When reading CSV files, the separator defaults to comma. Analysis shows that a cell in the read data contains two fields, that is, the value may contain two commas

Method B. open the file to another format required by the dataset. Do not be lazy and modify the suffix directly. For example, some formats can be modified by converting Excel to CSV and saving manually to ensure uniform format

The fundamental reason is that the data format is incorrect, which makes it impossible to read correctly. We should solve it from the aspect of file content format

(self: pyds.NvDsComp_BboxInfo) -> _NvBbox_Coords

Article catalog

Project scenario and Problem Description: Cause Analysis: solution:

Project scenario and Problem Description:

Call Python deepstream API and rewrite deepstream_ test_ 3. Py , the following error is reported:

TypeError: Unable to convert function return value to a Python type! The signature was
(self: pyds.NvDsComp_BboxInfo) -> _NvBbox_Coords

The box system configuration used this time is as follows:


Cause analysis:

Nvdscomp is missing from the current bindings_ Bboxinfo’s bindings, but you can follow this GitHub page https://github.com/mrtj/pyds_ tracker_ Similar steps published in meta create your own bindings.

Solution:

1. Download the file in the above link and unzip
2. Add pyds_ tracker_ Meta.cpp replace with pyds_ bbox_ Meta.cpp , the specific code is as follows:

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "nvdsmeta.h"
#include <iostream>
#include "nvll_osd_struct.h"
#include <pybind11/numpy.h>
using namespace std;
namespace py = pybind11;

PYBIND11_MODULE(pyds_bbox_meta, m) {
    m.doc() = "pybind11 wrapper to access Nvidia DeepStream detector bbox";

#define STRING_CHAR_ARRAY(TYPE, FIELD)                             \
        [](const TYPE &self)->string {                             \
            return string(self.FIELD);                             \
        },                                                         \
        [](TYPE &self, std::string str) {                          \
            int strSize = str.size();                              \
            str.copy(self.FIELD, strSize);                         \
        },                                                         \
        py::return_value_policy::reference

	py::class_<NvDsObjectMeta>(m,"NvDsObjectMeta",py::module_local())
                .def(py::init<>())
                .def_readwrite("base_meta", &NvDsObjectMeta::base_meta)
       
                .def_readwrite("parent", &NvDsObjectMeta::parent)
        
                .def_readwrite("unique_component_id", &NvDsObjectMeta::unique_component_id)
       
                .def_readwrite("class_id", &NvDsObjectMeta::class_id)        
        
                .def_readwrite("object_id", &NvDsObjectMeta::object_id)
        
                .def_readwrite("detector_bbox_info",&NvDsObjectMeta::detector_bbox_info)

                .def_readwrite("tracker_bbox_info",&NvDsObjectMeta::tracker_bbox_info) 
            
                .def_readwrite("confidence", &NvDsObjectMeta::confidence)

                .def_readwrite("tracker_confidence",&NvDsObjectMeta::tracker_confidence)
        
                .def_readwrite("rect_params", &NvDsObjectMeta::rect_params)

                .def_readwrite("mask_params",&NvDsObjectMeta::mask_params)
	
         
                .def_readwrite("text_params", &NvDsObjectMeta::text_params)
                
                .def("cast",[](void *data) {
                        return (NvDsObjectMeta*)data;},
                        py::return_value_policy::reference)
        
                .def_property("obj_label", STRING_CHAR_ARRAY(NvDsObjectMeta, obj_label))
                .def_readwrite("classifier_meta_list", &NvDsObjectMeta::classifier_meta_list)        
     
                .def_readwrite("obj_user_meta_list", &NvDsObjectMeta::obj_user_meta_list)
                .def_property("misc_obj_info",
				[](NvDsObjectMeta &self)->py::array {
					auto dtype=py::dtype(py::format_descriptor<int>::format());
                    auto base=py::array(dtype, {MAX_USER_FIELDS}, {sizeof(int)});
                    return py::array(dtype,{MAX_USER_FIELDS}, {sizeof(int)}, self.misc_obj_info,base);
				}, [](NvDsObjectMeta& self){})
                .def_property("reserved",
				[](NvDsObjectMeta &self)->py::array {
					auto dtype=py::dtype(py::format_descriptor<int>::format());
                    auto base=py::array(dtype, {MAX_RESERVED_FIELDS}, {sizeof(int)});
                    return py::array(dtype,{MAX_RESERVED_FIELDS}, {sizeof(int)}, self.reserved,base);
				}, [](NvDsObjectMeta& self){});

	py::class_<NvOSD_RectParams>(m,"NvOSD_RectParams",py::module_local())
                .def(py::init<>())
                .def_readwrite("left",&NvOSD_RectParams::left)
                .def_readwrite("top",&NvOSD_RectParams::top)
                .def_readwrite("width",&NvOSD_RectParams::width)
                .def_readwrite("height",&NvOSD_RectParams::height)
                .def_readwrite("border_width",&NvOSD_RectParams::border_width)
                .def_readwrite("border_color",&NvOSD_RectParams::border_color)
                .def_readwrite("has_bg_color",&NvOSD_RectParams::has_bg_color)
                .def_readwrite("reserved",&NvOSD_RectParams::reserved)
                .def_readwrite("bg_color",&NvOSD_RectParams::bg_color)
                .def_readwrite("has_color_info",&NvOSD_RectParams::has_color_info)
                .def_readwrite("color_id",&NvOSD_RectParams::color_id);
	py::class_<NvDsComp_BboxInfo>(m,"NvDsComp_BboxInfo",py::module_local())
                .def(py::init<>())

                .def_readwrite("org_bbox_coords",&NvDsComp_BboxInfo::org_bbox_coords);

	 py::class_<NvBbox_Coords>(m,"NvBbox_Coords",py::module_local())
            .def(py::init<>())
            .def_readwrite("left",&NvBbox_Coords::left)
            .def_readwrite("top",&NvBbox_Coords::top)
            .def_readwrite("width",&NvBbox_Coords::width)
            .def_readwrite("height",&NvBbox_Coords::height);
}

3. Change the relevant contents of build. Sh :

4. Change the relevant contents of setup. Py :

5. Run bash./build. Sh
6. Run Python setup. Py install (if necessary, use sudo or python3)
after completion, pyds will be generated_ bbox_ Meta.so file and build folder

7. In the original Python code, Import pyds_ bbox_ Meta , and the original obj_ meta = pyds.NvDsObjectMeta.cast(l_ Obj. Data) changed to obj_ meta = pyds_ bbox_ meta.NvDsObjectMeta.cast(l_ obj.data)

Examples are given below:

import pyds_bbox_meta
...  # add rest of callback code here
obj_meta=pyds_bbox_meta.NvDsObjectMeta.cast(l_obj.data)
det_info_left = obj_meta.detector_bbox_info.org_bbox_coords.left
det_info_top = obj_meta.detector_bbox_info.org_bbox_coords.top

If reading this article is useful to you, please pay attention to it and like the collection
July 23, 2021 17:39:31

Importerror: no module named typing error reporting solution (python2 PIP needs to be backed back from 21)

The default installation of PIP for python2 is version 21. This version is no longer supported, so an error is reported when executing pip. You need to back up the PIP version and execute the following command

curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
python -m pip install --upgrade "pip < 21.0"

[Solved] Conda Upgrade Error: PackageNotInstalledError: Package is not installed in prefix.

Use CONDA update CONDA to update CONDA. If you encounter a packagenotinstallederror problem, record it here!

Problem description

conda update –prefix /Users/omeiko/opt/miniconda3 anaconda
PackageNotInstalledError: Package is not installed in prefix.
prefix: /Users/omeiko/opt/miniconda3
package name: anaconda

When you run CONDA update, you will be prompted whether you want to run CONDA update — prefix/users/omeiko/opt/minicanda3 anaconda. After running, the above error prompt will be displayed
the reason for the problem is that you installed miniconda instead of anaconda.

 

Solution:

Method 1
execute CONDA install anaconda, install anaconda, and then run again.

Method 2
execute CONDA update — prefix/users/omeiko/opt/miniconda3 CONDA. There is no need to update anaconda
or execute CONDA update — name base CONDA (I solved it myself with this command) to update the base command

[Solved] Pygame Install Error: Command errored out with exit status 255: hg clone –noupdate -q https://bitbucket.o

report errors:

ERROR: Command errored out with exit status 255: hg clone –noupdate -q https://bitbucket.org/pygame/pygame /private/var/folders/jt/s0hr2mwx2f91p9xjm0r09vqr0000gn/T/pip-req-build-17brj_ kp Check the logs for full command output.

context:

Learn Python Programming: from introduction to practice. When you start the example practice in Chapter 12, you need to install the pyGame environment. You always report errors according to the methods in the book and cannot install normally.

terms of settlement:

Do not use the method in the book:
PIP3 install — user Hg+ https://bitbucket.org/pygame/pygame

Direct use

pip3 install pygame

I’m really good at installing it successfully

Mac Upgrade pip WARNING: You are using pip version 21.1.1; however, version 21.1.3 is available. You s

error:
WARNING: You are using pip version 21.1.1; however, version 21.1.3 is available.
You should consider upgrading via the ‘/usr/local/opt/[email protected]/bin/python3.9 -m pip install –upgrade pip’ command.
Error solution
I also used the Windows upgrade method and found that it didn’t work, what a fucking headache!
Windows pip upgrade link

The right solution
pip3 install –upgrade pip

[Solved] Can’t reconnect until invalid transaction is rolled back

The reason is that there is no call

session.rollback()

Solution:

@contextmanager
    def session_scope(self):
        self.db_engine = create_engine(self.db_config, pool_pre_ping=True) # echo=True if needed to see background SQL        
        Session = sessionmaker(bind=self.db_engine)
        session = Session()
        try:
            # this is where the "work" happens!
            yield session
            # always commit changes!
            session.commit()
        except:
            # if any kind of exception occurs, rollback transaction
            session.rollback()
            raise
        finally:
            session.close()

Another form:

        try:
        	......
            ......
            ......
            ......
        except Exception:
            import traceback
            traceback.print_exc()
            db.session.rollback()
            pass
        finally:
            db.session.close()
            pass

Sns.distplot Error: ‘Rectangle‘ object has no property ‘normed‘” [How to Solve]

Problem Description:
rectangular ‘object has no property’ normalized ‘in seaborn.distplot, but the normalized parameter is not used
reason:
the normalized parameter has been deprecated. The hist () histogram is built into plot, and the normalized parameter is the default parameter of hist
solution:
in Anaconda – > lib–> site-packages-> seaborn–> In distributions.py, change
hist around line 214 of the file_ kws.setdefault("normed", norm_ Hist)
is hist_ kws.setdefault("density", norm_ Hist)
restart

ImportError: cannot import name ‘SummaryWriter‘ from partially initialized module ‘torch.utils.tenso

ImportError: cannot import name 'SummaryWriter' from partially initialized module 'torch.utils.tensorboard' (most likely due to a circular import)

The reason for this is that the file you named is duplicate with the system file. Remember to check it and try to avoid duplication with the system name, otherwise it is easy to make mistakes when importing the package