That would be strange for it to behave differently like that. I would double-check that your username and password are exactly right.
Personally, I like to use an input to set the user/pass parameters rather than rely on hard-coded values. Try omitting the password parameter. When you specify a user w/o a password, it will automatically prompt you to enter your password using the getpass module, which hides the entered text like a standard password entry.
gis = GIS('portal-url', input('User: '))
If you're still getting the error, try omitting the user/password entirely to see if you can connect to the portal anonymously. This will at least confirm whether you are reaching the portal.
- Josh Carlson
Kendall County GIS