question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type error in python 3.6

See original GitHub issue

I get an error when I run migration in python-3.6

Traceback (most recent call last):
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/__init__.py", line 92, in run
    Main(config).execute()
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/main.py", line 50, in execute
    self._execution_log('\nStarting DB migration on host/database "%s/%s" with user "%s"...' % (self.config.get('database_host'), self.config.get('database_name'), self.config.get('database_user')), "PINK", log_level_limit=1)
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/main.py", line 254, in _execution_log
    CLI.msg(msg, color)
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/cli.py", line 243, in msg
    print("{}{}{}".format(cls.color[color], msg, cls.color["END"]))
  File "/Users/rajeev/Workspace/procure/procure-backend/bin/../lib/python3.6/codecs.py", line 377, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rajeev/Workspace/procure/procure-backend/bin/db-migrate", line 11, in <module>
    sys.exit(run_from_argv())
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/__init__.py", line 18, in run_from_argv
    run(options.__dict__)
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/__init__.py", line 96, in run
    CLI.error_and_exit(str(e))
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/cli.py", line 233, in error_and_exit
    cls.msg("[ERROR] %s\n" % msg, "RED")
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/cli.py", line 243, in msg
    print("{}{}{}".format(cls.color[color], msg, cls.color["END"]))
  File "/Users/rajeev/Workspace/procure/procure-backend/bin/../lib/python3.6/codecs.py", line 377, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
rajeev1982commented, Mar 1, 2018

Looks like the problem is LC_CTYPE. I added the below export in my bash profile and the problem seems to be resolved.

export LC_CTYPE=UTF-8

0reactions
rajeev1982commented, Feb 18, 2019

Try this if above doesn’t work

export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8

Read more comments on GitHub >

github_iconTop Results From Across the Web

8. Errors and Exceptions — Python 3.11.1 documentation
The last line of the error message indicates what happened. Exceptions come in different types, and the type is printed as part of...
Read more >
5. Built-in Exceptions — Python 3.6.3 documentation
User code can raise built-in exceptions. This can be used to test an exception handler or to report an error condition “just like”...
Read more >
Type error in python 3.6: Must be string not int - Stack Overflow
This will fix your issue as the int() function will cast the string to an int and then you should be able to...
Read more >
Python 3 - Exceptions Handling - Tutorialspoint
Standard Exceptions ; 26. TypeError. Raised when an operation or function is attempted that is invalid for the specified data type. ; 27....
Read more >
T164163 TestScriptHelp.test_imagecopy fails in python 3.6 ...
TestScriptHelp.test_imagecopy fails in python 3.6 with "TypeError: NoneType takes no arguments". Closed, ResolvedPublic. Actions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found