Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError: 'ascii' codec can't encode character '\u25cf' in position 9: ordinal not in range(128) #31

Open
endrebak opened this issue Mar 18, 2019 · 3 comments

Comments

@endrebak
Copy link

When using Bullet I always get this error.


  File "bin/extract_genotypes", line 28, in <module>
    result = cli.launch()
  File "/home/endrebak/anaconda3/lib/python3.6/site-packages/bullet/client.py", line 670, in launch
    self.result.append((ui.prompt, ui.launch()))
  File "/home/endrebak/anaconda3/lib/python3.6/site-packages/bullet/client.py", line 213, in launch
    self.renderBullets()
  File "/home/endrebak/anaconda3/lib/python3.6/site-packages/bullet/client.py", line 157, in renderBullets
    self.printBullet(i)
  File "/home/endrebak/anaconda3/lib/python3.6/site-packages/bullet/client.py", line 165, in printBullet
    utils.cprint("{}".format(self.bullet) + " " * self.margin, self.bullet_color, back_color, end = '')
  File "/home/endrebak/anaconda3/lib/python3.6/site-packages/bullet/utils.py", line 119, in cprint
    forceWrite(on + color + s + colors.RESET, end = end)
  File "/home/endrebak/anaconda3/lib/python3.6/site-packages/bullet/utils.py", line 101, in forceWrite
    sys.stdout.write(s + end)
UnicodeEncodeError: 'ascii' codec can't encode character '\u25cf' in position 9: ordinal not in range(128)
@rcfox
Copy link
Contributor

rcfox commented Mar 19, 2019

Does it work if you run it with the environment variable PYTHONIOENCODING=utf8?

@endrebak
Copy link
Author

endrebak commented Mar 20, 2019

Yes! Thanks. But the reason I'm using bullet is so that noobs do not need to use scary command line options. I do not want people having to rely on setting env variables. Is there a way to fix this in my python code? You can use sys to set the default encoding, but this is a no-no according to google. Perhaps bullet should print a helpful error message that explains why this happens at least?

@rcfox
Copy link
Contributor

rcfox commented Mar 20, 2019

Definitely, this isn't a proper solution, just the easiest way of tracking down the issue.

It is strange though because utf8 should be the default for Python 3. Do you have a different file encoding specified for your own code?

I think the issue is that unicode ● character (\u25cf) in the source file. If you've copied that into your own code with a different file encoding, that could problems.

Also, what do you get from import sys; print(sys.getdefaultencoding())?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants