如何解决ImportError:无法在Python中导入名称json_format

时间:2016-12-31 21:32:07

标签: python json python-2.7 tensorflow

正在运行一个甚至不需要json的python / tensorflow程序,当这个消息弹出时 - 我试着做pip install json_format,它运行正常,但没有解决问题。这是在我在我的代码中实现“import tensorflow as tf”之后开始的,以修复我在tf未被识别的地方遇到的另一个问题。我在linux-ubuntu系统上运行python 2.7。

感谢任何帮助。以下是完整的错误文本:

@objc(mapView:didTapMarker:) func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
    if z == 0 {
        print("\(marker) tapped")

        let lat = marker.position.latitude as Double
        let long = marker.position.longitude as Double


        let tempMarker = getMarkerForLongAndLat(long: long, lat: lat, markers: markers)
        let index = getIndexForMarker(marker: tempMarker)

        getInfo(self.markersID[index]) {
            PFFile in
            self.imageFile?.getDataInBackground(block: { (imageData, error) in
                if(imageData != nil) {
                    self.fullImage = UIImage(data: imageData!)
                }
            })
            self.performSegue(withIdentifier: "playerSegue", sender: nil)
        }
    }
    return true
}


func getInfo(_ markerID : String, completion: @escaping (PFFile) -> Void)
{
    self.group.enter()

    print("printing")
    print(markerLat)
    print(markerLong)
    print(postsLat)
    print(postsLong)
    print("A")
    let query = PFQuery(className:"Posted")
    print("b")
    print(markerID)

    //query.whereKey("GPS", equalTo: PFGeoPoint(latitude: markerLat, longitude: markerLong))
    query.whereKey("objectId", equalTo: "\(markerID)")
    query.findObjectsInBackground { (objects, error) in
        print("c")
        if(error == nil)
        {
            print("d")

            for object in objects!
            {


                print("made it")
                self.imageFile = (object.object(forKey: "ImageFile") as! PFFile?)
                self.userofVideo = object.object(forKey: "User") as AnyObject?
                self.hour = object.object(forKey: "Hour") as AnyObject?
                self.minutes = object.object(forKey: "minutes") as AnyObject?
                self.streetName = object.object(forKey: "Location") as AnyObject?

                self.tempLat = (object.object(forKey: "GPS")! as AnyObject).latitude as Double
                self.tempLong = (object.object(forKey: "GPS")! as AnyObject).longitude as Double
                self.currentText = (object.object(forKey: "text")! as Any? as! String?)
                self.tempCoordinates = CLLocationCoordinate2D(latitude: self.tempLat! as CLLocationDegrees, longitude: self.tempLong! as CLLocationDegrees)
                //print(tempLong)

            }

        }
        else
        {
            print("didn't make it")
            print(error)
        }
        completion(self.imageFile!)
    }
    self.group.leave()

}

0 个答案:

没有答案