Request has type LocalProxy, but expected one of: bytes, unicodeWhat is the best way to remove accents in a Python unicode string?Convert bytes to a string?Best way to convert string to bytes in Python 3?How can I tag and chunk French text using NLTK and Python?TypeError: a bytes-like object is required, not 'str' when writing to a file in Python3google speech api Invalid recognitionErrors with a Golang web app hosted in a Google App Engine environment; the app front-ends BigQueryerror while importing WriteToDatastore (Apache Beam/Google DataFlow)Analysing large body of text with Google Cloud Natural Language API - receiving ssl.SSLError: ('The read operation timed out',)Can aws comprehend be used in splitting documents to sentences?

Professor falsely accusing me of cheating in a class he does not teach, two months after end of the class. What precautions should I take?

The monorail explodes before I can get on it

Does Google Maps take into account hills/inclines for route times?

Best wood species for extreme bends?

Do native speakers use ZVE or CPU?

Does Ubuntu Server 18.04.2 LTS "track" users in any way?

Were there any new Pokémon introduced in the movie Pokémon: Detective Pikachu?

How does a Potion of Poison work?

Is there a word for a message that is intended to be intercepted by an adversary?

How can I deal with a player trying to insert real-world mythology into my homebrew setting?

How can I get both Giga Drain and Mach Punch on Breloom?

As the Dungeon Master, how do I handle a player that insists on a specific class when I already know that choice will cause issues?

Matchmaker, Matchmaker, make me a match

Shortest distance around a pyramid?

During copyediting, journal disagrees about spelling of paper's main topic

Overlapping vs Non-overlapping returns

QGIS Welcome page: What is 'pin to list' for?

Why is dry soil hydrophobic? Bad gardener paradox

Filtering fine silt/mud from water (not necessarily bacteria etc.)

Would letting a multiclass character rebuild their character to be single-classed be game-breaking?

Referring to different instances of the same character in time travel

Print the last, middle and first character of your code

How did the hit man miss?

Cops: The Hidden OEIS Substring



Request has type LocalProxy, but expected one of: bytes, unicode


What is the best way to remove accents in a Python unicode string?Convert bytes to a string?Best way to convert string to bytes in Python 3?How can I tag and chunk French text using NLTK and Python?TypeError: a bytes-like object is required, not 'str' when writing to a file in Python3google speech api Invalid recognitionErrors with a Golang web app hosted in a Google App Engine environment; the app front-ends BigQueryerror while importing WriteToDatastore (Apache Beam/Google DataFlow)Analysing large body of text with Google Cloud Natural Language API - receiving ssl.SSLError: ('The read operation timed out',)Can aws comprehend be used in splitting documents to sentences?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to use the Google Cloud Platform Natural Language API with Python within a Google Cloud Function. Whenever I use the code provided in this Google tutorial for analyzing entity analysis using text in Cloud Storage, I get the following error message:



 File "/user_code/main.py", line 9, in entity_sentiment_file
type=enums.Document.Type.PLAIN_TEXT)
TypeError: <Request 'http://25e4801f1004e4eb41d11633d9b2e9e9-dot-ad6bdc7c397c15e62-tp.appspot.com/'
[POST]> has type LocalProxy, but expected one of: bytes, unicode


I obtain that error message after successfully deploying the function and clicking "Test the Function" with a triggering event of empty curly braces , then going to the View Logs page.



I've tried providing the test event parameters like below, but I obtained the same result.



"gcs_uri":"gs://test-news-articles/news-article-1.txt"


Here's my entire function:



from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types

def entity_sentiment_file(gcs_uri,request=None):
print('gcs_uri: '.format(gcs_uri))
client = language.LanguageServiceClient()
document = types.Document(
gcs_content_uri=gcs_uri,
type=enums.Document.Type.PLAIN_TEXT)

# Detect and send native Python encoding to receive correct word offsets.
encoding = enums.EncodingType.UTF32
if sys.maxunicode == 65535:
encoding = enums.EncodingType.UTF16

result = client.analyze_entity_sentiment(document, encoding)

for entity in result.entities:
print(u'Name: ""'.format(entity.name))
for mention in entity.mentions:
print(u' Begin Offset : '.format(mention.text.begin_offset))
print(u' Content : '.format(mention.text.content))
print(u' Magnitude : '.format(mention.sentiment.magnitude))
print(u' Sentiment : '.format(mention.sentiment.score))
print(u' Type : '.format(mention.type))
print(u'Salience: '.format(entity.salience))
print(u'Sentiment: n'.format(entity.sentiment))


Any help would be much appreciated.










share|improve this question






























    1















    I'm trying to use the Google Cloud Platform Natural Language API with Python within a Google Cloud Function. Whenever I use the code provided in this Google tutorial for analyzing entity analysis using text in Cloud Storage, I get the following error message:



     File "/user_code/main.py", line 9, in entity_sentiment_file
    type=enums.Document.Type.PLAIN_TEXT)
    TypeError: <Request 'http://25e4801f1004e4eb41d11633d9b2e9e9-dot-ad6bdc7c397c15e62-tp.appspot.com/'
    [POST]> has type LocalProxy, but expected one of: bytes, unicode


    I obtain that error message after successfully deploying the function and clicking "Test the Function" with a triggering event of empty curly braces , then going to the View Logs page.



    I've tried providing the test event parameters like below, but I obtained the same result.



    "gcs_uri":"gs://test-news-articles/news-article-1.txt"


    Here's my entire function:



    from google.cloud import language
    from google.cloud.language import enums
    from google.cloud.language import types

    def entity_sentiment_file(gcs_uri,request=None):
    print('gcs_uri: '.format(gcs_uri))
    client = language.LanguageServiceClient()
    document = types.Document(
    gcs_content_uri=gcs_uri,
    type=enums.Document.Type.PLAIN_TEXT)

    # Detect and send native Python encoding to receive correct word offsets.
    encoding = enums.EncodingType.UTF32
    if sys.maxunicode == 65535:
    encoding = enums.EncodingType.UTF16

    result = client.analyze_entity_sentiment(document, encoding)

    for entity in result.entities:
    print(u'Name: ""'.format(entity.name))
    for mention in entity.mentions:
    print(u' Begin Offset : '.format(mention.text.begin_offset))
    print(u' Content : '.format(mention.text.content))
    print(u' Magnitude : '.format(mention.sentiment.magnitude))
    print(u' Sentiment : '.format(mention.sentiment.score))
    print(u' Type : '.format(mention.type))
    print(u'Salience: '.format(entity.salience))
    print(u'Sentiment: n'.format(entity.sentiment))


    Any help would be much appreciated.










    share|improve this question


























      1












      1








      1








      I'm trying to use the Google Cloud Platform Natural Language API with Python within a Google Cloud Function. Whenever I use the code provided in this Google tutorial for analyzing entity analysis using text in Cloud Storage, I get the following error message:



       File "/user_code/main.py", line 9, in entity_sentiment_file
      type=enums.Document.Type.PLAIN_TEXT)
      TypeError: <Request 'http://25e4801f1004e4eb41d11633d9b2e9e9-dot-ad6bdc7c397c15e62-tp.appspot.com/'
      [POST]> has type LocalProxy, but expected one of: bytes, unicode


      I obtain that error message after successfully deploying the function and clicking "Test the Function" with a triggering event of empty curly braces , then going to the View Logs page.



      I've tried providing the test event parameters like below, but I obtained the same result.



      "gcs_uri":"gs://test-news-articles/news-article-1.txt"


      Here's my entire function:



      from google.cloud import language
      from google.cloud.language import enums
      from google.cloud.language import types

      def entity_sentiment_file(gcs_uri,request=None):
      print('gcs_uri: '.format(gcs_uri))
      client = language.LanguageServiceClient()
      document = types.Document(
      gcs_content_uri=gcs_uri,
      type=enums.Document.Type.PLAIN_TEXT)

      # Detect and send native Python encoding to receive correct word offsets.
      encoding = enums.EncodingType.UTF32
      if sys.maxunicode == 65535:
      encoding = enums.EncodingType.UTF16

      result = client.analyze_entity_sentiment(document, encoding)

      for entity in result.entities:
      print(u'Name: ""'.format(entity.name))
      for mention in entity.mentions:
      print(u' Begin Offset : '.format(mention.text.begin_offset))
      print(u' Content : '.format(mention.text.content))
      print(u' Magnitude : '.format(mention.sentiment.magnitude))
      print(u' Sentiment : '.format(mention.sentiment.score))
      print(u' Type : '.format(mention.type))
      print(u'Salience: '.format(entity.salience))
      print(u'Sentiment: n'.format(entity.sentiment))


      Any help would be much appreciated.










      share|improve this question
















      I'm trying to use the Google Cloud Platform Natural Language API with Python within a Google Cloud Function. Whenever I use the code provided in this Google tutorial for analyzing entity analysis using text in Cloud Storage, I get the following error message:



       File "/user_code/main.py", line 9, in entity_sentiment_file
      type=enums.Document.Type.PLAIN_TEXT)
      TypeError: <Request 'http://25e4801f1004e4eb41d11633d9b2e9e9-dot-ad6bdc7c397c15e62-tp.appspot.com/'
      [POST]> has type LocalProxy, but expected one of: bytes, unicode


      I obtain that error message after successfully deploying the function and clicking "Test the Function" with a triggering event of empty curly braces , then going to the View Logs page.



      I've tried providing the test event parameters like below, but I obtained the same result.



      "gcs_uri":"gs://test-news-articles/news-article-1.txt"


      Here's my entire function:



      from google.cloud import language
      from google.cloud.language import enums
      from google.cloud.language import types

      def entity_sentiment_file(gcs_uri,request=None):
      print('gcs_uri: '.format(gcs_uri))
      client = language.LanguageServiceClient()
      document = types.Document(
      gcs_content_uri=gcs_uri,
      type=enums.Document.Type.PLAIN_TEXT)

      # Detect and send native Python encoding to receive correct word offsets.
      encoding = enums.EncodingType.UTF32
      if sys.maxunicode == 65535:
      encoding = enums.EncodingType.UTF16

      result = client.analyze_entity_sentiment(document, encoding)

      for entity in result.entities:
      print(u'Name: ""'.format(entity.name))
      for mention in entity.mentions:
      print(u' Begin Offset : '.format(mention.text.begin_offset))
      print(u' Content : '.format(mention.text.content))
      print(u' Magnitude : '.format(mention.sentiment.magnitude))
      print(u' Sentiment : '.format(mention.sentiment.score))
      print(u' Type : '.format(mention.type))
      print(u'Salience: '.format(entity.salience))
      print(u'Sentiment: n'.format(entity.sentiment))


      Any help would be much appreciated.







      python-3.x google-cloud-platform nlp google-cloud-functions google-natural-language






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 20:14









      Dustin Ingram

      5,7351 gold badge19 silver badges37 bronze badges




      5,7351 gold badge19 silver badges37 bronze badges










      asked Mar 26 at 4:02









      Spencer GoffSpencer Goff

      1201 gold badge4 silver badges14 bronze badges




      1201 gold badge4 silver badges14 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          2














          A function that responds to an HTTP request needs to have the signature:



          def my_function(request):
          ...


          where request is provided by the Cloud Functions runtime on every new request.



          Right now, gcs_uri is getting set to the request value (which is a LocalProxy type) and then you're trying to format a string with it, which causes the exception.



          I'm not sure where you're expecting gcs_uri to come from, but it won't be provided to the function as an argument. If you're making a request with JSON, it will be available using request.json['gcs_uri']. See "Writing HTTP Functions" for more details.






          share|improve this answer

























          • Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

            – Spencer Goff
            Mar 27 at 5:20










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349659%2frequest-has-type-localproxy-but-expected-one-of-bytes-unicode%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          A function that responds to an HTTP request needs to have the signature:



          def my_function(request):
          ...


          where request is provided by the Cloud Functions runtime on every new request.



          Right now, gcs_uri is getting set to the request value (which is a LocalProxy type) and then you're trying to format a string with it, which causes the exception.



          I'm not sure where you're expecting gcs_uri to come from, but it won't be provided to the function as an argument. If you're making a request with JSON, it will be available using request.json['gcs_uri']. See "Writing HTTP Functions" for more details.






          share|improve this answer

























          • Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

            – Spencer Goff
            Mar 27 at 5:20















          2














          A function that responds to an HTTP request needs to have the signature:



          def my_function(request):
          ...


          where request is provided by the Cloud Functions runtime on every new request.



          Right now, gcs_uri is getting set to the request value (which is a LocalProxy type) and then you're trying to format a string with it, which causes the exception.



          I'm not sure where you're expecting gcs_uri to come from, but it won't be provided to the function as an argument. If you're making a request with JSON, it will be available using request.json['gcs_uri']. See "Writing HTTP Functions" for more details.






          share|improve this answer

























          • Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

            – Spencer Goff
            Mar 27 at 5:20













          2












          2








          2







          A function that responds to an HTTP request needs to have the signature:



          def my_function(request):
          ...


          where request is provided by the Cloud Functions runtime on every new request.



          Right now, gcs_uri is getting set to the request value (which is a LocalProxy type) and then you're trying to format a string with it, which causes the exception.



          I'm not sure where you're expecting gcs_uri to come from, but it won't be provided to the function as an argument. If you're making a request with JSON, it will be available using request.json['gcs_uri']. See "Writing HTTP Functions" for more details.






          share|improve this answer















          A function that responds to an HTTP request needs to have the signature:



          def my_function(request):
          ...


          where request is provided by the Cloud Functions runtime on every new request.



          Right now, gcs_uri is getting set to the request value (which is a LocalProxy type) and then you're trying to format a string with it, which causes the exception.



          I'm not sure where you're expecting gcs_uri to come from, but it won't be provided to the function as an argument. If you're making a request with JSON, it will be available using request.json['gcs_uri']. See "Writing HTTP Functions" for more details.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 27 at 15:13

























          answered Mar 26 at 20:13









          Dustin IngramDustin Ingram

          5,7351 gold badge19 silver badges37 bronze badges




          5,7351 gold badge19 silver badges37 bronze badges












          • Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

            – Spencer Goff
            Mar 27 at 5:20

















          • Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

            – Spencer Goff
            Mar 27 at 5:20
















          Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

          – Spencer Goff
          Mar 27 at 5:20





          Thanks! I understand now. I made my function parameter just "request", made my test event "gcs_uri": "gs://test-news-articles/news-article-1.txt", and can access gcs_uri using request_json['gcs_uri'].

          – Spencer Goff
          Mar 27 at 5:20








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349659%2frequest-has-type-localproxy-but-expected-one-of-bytes-unicode%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해