Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:31:04+00:00 2026-06-11T08:31:04+00:00

I have a python script that I cobbled together that checks my gmail via

  • 0

I have a python script that I cobbled together that checks my gmail via the rss feed and outputs the text to the screen. It worked on python 2.6.6 but I’ve been unsuccessful to get it working under python 3.2.3.
I’ve used 2to3 to convert it. The code is here:https://www.dropbox.com/s/b1277mi7vc7hv3f/gmailcheckparseconky.py3

The problem occurs in the ObtainEmailFeed function.

I get the dreaded “TypeError("expected bytes, not %s" % s.__class__.__name__)” error when I use

b64auth = base64.encodestring("%s:%s" % (user, password))

however when I use

string = bytes("%s:%s" % (user,password), 'utf-8')
string2=str(string,'utf-8')
b64auth = base64.encodestring( string)

I get

auth = "Basic " + b64auth
TypeError: Can't convert 'bytes' object to str implicitly

which seems to bring the whole problem back full circle.

I’ve tried hard coding in my password as text and that doesn’t work. I get an
urllib.error.HTTPError: HTTP Error 401: Unauthorized when I set `auth = “Basic user:password”

As I said I cobbled the code together. I don’t fully understand what gmail needs for me to authorize. Continuing along with that vein, I’d prefer help in fixing this code so I can learn and get a better understanding of python instead of pointing me to another script on the web that does the same/similar thing as to what I’m doing.

Thanks in advance,
Nick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:31:06+00:00Added an answer on June 11, 2026 at 8:31 am

    Since python3 there is a distinction between bytes and strings. The error comes from the fact that base64.encodestring is now a deprecated alias for encodebytes (see also: http://docs.python.org/py3k/library/base64.html#module-base64), and so it wants you to give bytes, and it will give you bytes back.

    You might want to do:

    string = bytes("%s:%s" % (user,password), 'utf-8')
    b64bytes = base64.encodebytes(string)
    b64auth = b64bytes.decode('ascii')
    

    Then b64auth will be a string and you will be able to use it as string in rest of the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python script that takes the directory path of a text file
The scenario: We have a python script that checks thousands of proxys simultaneously. The
I have a Python script that outputs two numbers like so: 1.0 2.0 (that's
I have a python script that checks code for coding convention errors. It does
I have a python script that checks a certain folder for new files and
I have python script that uses pysvn and checks out or updates a local
I have a python script that analyzes a set of error messages and checks
I have a python script that is writing text to images using the PIL.
I have a python script that runs continuously. It outputs 2 lines of info
I have a python script that runs a program, which generates few .exe files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.