Something in your program is trying to call the startswith method of an object, probably because it expects it to be a string. You'll have to pay attention to the traceback to see what it is being called on, and why that is an integer instead of a string. Did you pass along an integer where a string was expected?

Answer from Thomas Wouters on Stack Overflow
🌐
GitHub
github.com › martinblech › xmltodict › issues › 249
AttributeError: 'int' object has no attribute 'startswith' · Issue #249 · martinblech/xmltodict
June 5, 2020 - Traceback (most recent call last): ...asxp\Miniconda3\envs\nfb_studio\lib\site-packages\xmltodict.py", line 388, in _emit if ik.startswith(attr_prefix): AttributeError: 'int' object has no attribute 'startswith'...
Author   martinblech
Discussions

classification report throws 'int' object has no attribute 'startswith'
I am trying to print a Classification report and I get the below error: I did check if any int values are passed in the list and there were none, infact I also made sure to convert them to string b... More on github.com
🌐 github.com
1
February 22, 2022
python - Trying to get rid of "AttributeError: 'int' object has no attribute 'startswith' " when using while loop - Stack Overflow
Okay, thanks Engr1hmh, i've changed the assignment from line =0 to count= 0 instead. Now in addition to "count" variable I have modified the while block to below. while count< line_count: if line.startswith("From"): print(line) count= count+ 1 Now i don't get any output whatsoever. More on stackoverflow.com
🌐 stackoverflow.com
'int' object has no attribute 'startswith' when using an int as key
Hi, I get: 'int' object has no attribute 'startswith' when trying to give an int as a key. Details: File "/usr/local/lib/python3.4/dist-packages/pickleshare.py", line 90, ... More on github.com
🌐 github.com
1
March 30, 2016
Command raised an exception: AttributeError: 'int' object has no attribute 'startswith'
get_playlist(str, int) · AppData\Local\Programs\Python\Python39\lib\site-packages\ytmusicapi\mixins\playlists.py", line 63, in get_playlist browseId = "VL" + playlistId if not playlistId.startswith("VL") else playlistId More on github.com
🌐 github.com
1
March 25, 2021
🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-int-object-has-no-attribute
AttributeError: 'int' object has no attribute 'X' (Python) | bobbyhadz
To solve the error in the example, we would have to convert the integer to a string to be able to access the string-specific startswith() method. ... A common cause of the error is trying to call the str.isdigit() method on an integer.
🌐
GitHub
github.com › chakki-works › seqeval › issues › 87
classification report throws 'int' object has no attribute 'startswith' · Issue #87 · chakki-works/seqeval
February 22, 2022 - I am trying to print a Classification report and I get the below error: I did check if any int values are passed in the list and there were none, infact I also made sure to convert them to string b...
Author   chakki-works
🌐
Narkive
archetypes-devel.narkive.com › 8ZOrtQQQ › attributeerror-int-object-has-no-attribute-startswith
AttributeError: 'int' object has no attribute 'startswith'
Permalink Everything fine with my AGX generated schema, but suddenly i got this error, when storing an ATCT AttributeError: 'int' object has no attribute 'startswith' this happens when i use "int" fields, or when using (and selecting) an reference. I cannot recreate the point when this behaviour ...
🌐
Python
bugs.python.org › issue8570
Issue 8570: 2to3 crashes with "AttributeError: 'int' object has no attribute 'startswith'" - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/52816
🌐
Stack Overflow
stackoverflow.com › questions › 66929877 › trying-to-get-rid-of-attributeerror-int-object-has-no-attribute-startswith
python - Trying to get rid of "AttributeError: 'int' object has no attribute 'startswith' " when using while loop - Stack Overflow
Now I got it, in this line of your code while line < line_count: if line.startswith("From:"): print(line) line = line +1 replace line with i 2021-04-03T11:39:35.543Z+00:00 ... In your first code the line corresponds to the line of .txt which would be a string value. fhand = open('mbox-short.txt') for line in fhand: if line.startswith('From:'): print(line) Whereas in the other code you are declaring line as int value:
🌐
M5Stack Community
community.m5stack.com › topic › 5805 › int-object-has-no-attribute-startwith-error-when-trying-to-use-an-image
'int' object has no attribute 'startwith' ERROR when trying to use an image | M5Stack Community
November 14, 2023 - Details of the error say the following: File "<string>", line 39 in <module> // I think it refers to this line: image0 = M5Img(135, 82, "res/error.png", True) File "m5stack_ui.py", line 513, in _ init _ AttributeError: 'int' object has no attribute 'startswith'
Find elsewhere
🌐
SourceForge
sourceforge.net › home › browse › oblivion works › bugs
Oblivion Works / Bugs / #260 'int' object has no attribute 'startswith'
May 28, 2013 - Reported here (and here) - and I've sure seen this before · trira had some more information on this bug:
🌐
GitHub
github.com › getsentry › sentry › issues › 1923
'int' object has no attribute 'startswith' · Issue #1923 · getsentry/sentry
File "sentry/interfaces/exception.py", line 216, in compute_hashes system_hash = self.get_hash(system_frames=True) File "sentry/interfaces/exception.py", line 234, in get_hash system_frames=system_frames, File "sentry/interfaces/stacktrace.py", line 526, in get_hash output.extend(frame.get_hash()) File "sentry/interfaces/stacktrace.py", line 285, in get_hash elif self.function and self.is_unhashable_function(): File "sentry/interfaces/stacktrace.py", line 260, in is_unhashable_function return self.function.startswith(('lambda$', '[Anonymous'))
Author   getsentry
🌐
Narkive
python-bugs-list.python.narkive.com › xDYCLAcz › issue8570-2to3-crashes-with-attributeerror-int-object-has-no-attribute-startswith
[issue8570] 2to3 crashes with "AttributeError: 'int' object has no attribute 'startswith'"
---------- components: 2to3 (2.x to 3.0 conversion tool) files: 2to3_crash.py messages: 104518 nosy: rom16384 priority: normal severity: normal status: open title: 2to3 crashes with "AttributeError: 'int' object has no attribute 'startswith'" type: crash versions: Python 2.6 Added file: ...
🌐
GitHub
github.com › pickleshare › pickleshare › issues › 20
'int' object has no attribute 'startswith' when using an int as key · Issue #20 · ipython/pickleshare
March 30, 2016 - Hi, I get: 'int' object has no attribute 'startswith' when trying to give an int as a key. Details: File "/usr/local/lib/python3.4/dist-packages/pickleshare.py", line 90, ...
Author   ipython
🌐
GitHub
github.com › sigma67 › ytmusicapi › issues › 182
Command raised an exception: AttributeError: 'int' object has no attribute 'startswith' · Issue #182 · sigma67/ytmusicapi
March 25, 2021 - get_playlist(str, int) · AppData\Local\Programs\Python\Python39\lib\site-packages\ytmusicapi\mixins\playlists.py", line 63, in get_playlist browseId = "VL" + playlistId if not playlistId.startswith("VL") else playlistId
Author   sigma67
🌐
Reddit
reddit.com › r/learnpython › getting a 'nonetype' object has no attribute 'startswith' attributeerror, and i cant figure it out.
r/learnpython on Reddit: Getting a 'NoneType' object has no attribute 'startswith' AttributeError, and i cant figure it out.
July 22, 2018 -

So ive googled and tried to change my code based on the other answers ive found, but i keep getting that error code.

Here is my code:

def genre_find(user_id):
    global response_user_id
    global response
    global genreif
    if response_user_id != user_id:
        response = requests.get('https://www.fanfiction.net/u/{}'.format(user_id))
        response_user_id = user_id
        sleep(randint(3, 4))
    if response.status_code == requests.codes.ok:
        soup = bs(response.text, 'html.parser')
        user_info = soup.select("#content_wrapper_inner table table tr td")
        my_stories = soup.select("div.mystories")
        genre = None
        for story in my_stories:
            genre = story.find_all("div")[-1].text.split(" - ")[3]
           return genre
        genreif = genre.startswith('Chap')
    return genreif

Error: (line 17 here)

  File "test_two.py", line 74, in <module>
user_write_story_data = get_user_information(user_id)
File "test_two.py", line 42, in get_user_information
genre_find(user_id)
File "test_two.py", line 34, in genre_find
genreif = genre.startswith('Chap')
AttributeError: 'NoneType' object has no attribute 'startswith'
🌐
GitHub
github.com › wrye-bash › wrye-bash › issues › 95
'int' object has no attribute 'startswith' · Issue #95 · wrye-bash/wrye-bash
May 31, 2014 - svn OP: Reported here (and here) - and I've sure seen this before Daidalos commented: trira had some more information on this bug: It's been around for a while. It's caused by having the following options in Race Record >selected: "Races...
Author   wrye-bash
🌐
SABnzbd Forums
forums.sabnzbd.org › home › board index › other languages › nederlands
AttributeError: 'int' object has no attribute 'startswith' - SABnzbd Forums
March 14, 2010 - Ik heb een upgrade gedaan naar ... cherryport, https_port) File "/opt/SABnzbd/SABnzbd.py", line 445, in get_webhost if ip.startswith('169.254.'): AttributeError: 'int' object has no attribute 'startswith' Op de verschillende formus gezocht maar geen oplossing gevonden, iemand ...
🌐
GitHub
github.com › saulpw › visidata › issues › 800
view_pandas(df.transpose()) raises AttributeError: 'int' object has no attribute 'startswith' · Issue #800 · saulpw/visidata
November 21, 2020 - AttributeError: 'int' object has no attribute 'startswith' A temporary fix is to do · df.columns = df.columns.map(str) but using such a transposed version of data is very, very slow. Any idea? Kind regards · Related #129, #631 (about transpose on visidata side) No one assigned ·
Author   saulpw
🌐
Reddit
reddit.com › r/learnpython › attributeerror: 'nonetype' object has no attribute 'startswith'
r/learnpython on Reddit: AttributeError: 'NoneType' object has no attribute 'startswith'
September 22, 2021 -

I've been working on setting up a "simple" Flask app with a cloud-hosted postgres database.

My app's config.py file includes the following code:

SQLALCHEMY_DATABASE_URI = os.environ.get('dbs_url')
  if os.environ.get('dbs_url').startswith('postgres') :
      SQLALCHEMY_DATABASE_URI = os.environ.get('dbs_url').replace('postgres', 'postgresql')

Long story short, this is included because ElephantSQL starts their database URLs with "postgres" while SQLAlchemy expects them to begin with "postgresql".

Generally speaking this has worked just fine.

Now, though, I'm in a situation where I need to edit a local database entry directly (I added a new column to an existing table). As far as I know I need to enter Python's shell and import the database model that represents the offending table, like >>> from [app] import [Class]. Apparently doing that involves pulling from the config.py file somehow, because when I try importing a model I get the following error:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\Users\colby\coding_temple\assignments\week_5\01\homework\app\
  from config import Conf
 File "C:\Users\colby\coding_temple\assignments\week_5\01\homework\conf
  class Conf:
 File "C:\Users\colby\coding_temple\assignments\week_5\01\homework\conf
  if os.environ.get('dbs_url').startswith('postgres'):
AttributeError: 'NoneType' object has no attribute 'startswith'

Regardless of whether what I'm doing makes any sense (I'm sure it doesn't), I'd like to re-write this in a way that doesn't cause this error.

Edit: I was indeed doing something that didn't make any sense. I didn't need to try this at all, just delete a row from my ElephantSQL database. Not sure why I thought there was something locally

🌐
Team Treehouse
teamtreehouse.com › community › int-object-has-no-attribute-numdie
int object has no attribute 'num_die' (Example) | Treehouse Community
August 17, 2021 - I set this up a bit differently from the video, but it seems like it should work. PyCharm tells me the num_die attribute is an integer, but when the code runs, it says int object has no attribute 'num_die' The die class and the die roller class work just fine, but then it stops in the for-loop of the dice_hand method.