Traceback (most recent call last):
File "/Applications/Sublime
Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
return self.run(edit)
File "open_in_browser in /Applications/Sublime
Text.app/Contents/MacOS/Packages/Default.sublime-package", line 9, in run
File "./python3.3/webbrowser.py", line 70, in open_new_tab
File "./python3.3/webbrowser.py", line 62, in open
File "./python3.3/webbrowser.py", line 635, in open
UnicodeEncodeError: 'ascii' codec can't encode characters in position
56-57: ordinal not in range(128)
How can i fix this? I use the plugin SidebarEnhancements to open my html,but I meet this problem.
Related
I want to use Facebook's prophet,however when I try to create a model:
model = prt.Prophet(stan_backend='CMDSTANPY')
It occurs mistake like this:
Traceback (most recent call last):
File "C:\Users\UserName\IdeaProjects\station-simulate\stcd-predict.py", line 24, in <module>
model = prt.Prophet(stan_backend='CMDSTANPY')
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\forecaster.py", line 142, in __init__
self._load_stan_backend(stan_backend)
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\forecaster.py", line 153, in _load_stan_backend
self.stan_backend = StanBackendEnum.get_backend_class(stan_backend)()
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\models.py", line 67, in __init__
super().__init__()
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\models.py", line 23, in __init__
self.model = self.load_model()
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\models.py", line 79, in load_model
return cmdstanpy.CmdStanModel(exe_file=model_file)
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\cmdstanpy\model.py", line 192, in __init__
do_command(['where.exe', 'tbb.dll'], fd_out=None)
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\cmdstanpy\utils\command.py", line 53, in do_command
line = proc.stdout.readline()
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
If I don't use stan_backend='CMDSTANPY':
Traceback (most recent call last):
File "C:\Users\k6789\IdeaProjects\station-simulate\stcd-predict.py", line 24, in <module>
model = prt.Prophet()
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\forecaster.py", line 141, in __init__
self._load_stan_backend(stan_backend)
File "C:\ProgramData\Anaconda3\envs\my1stconda\lib\site-packages\prophet\forecaster.py", line 154, in _load_stan_backend
logger.debug("Loaded stan backend: %s", self.stan_backend.get_type())
AttributeError: 'Prophet' object has no attribute 'stan_backend'
I re-setup prophet with micromamba and it has no effect.
How to solve this?
Now I changed another computer and created a new conda environment,solved this.
I am trying to execute a read file command from command line inside a container in k8s for a django app but i get this error. I am able to execute the same command locally but not inside k8s. My complete error stack is as follows:
raceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/code/setup/management/commands/load.py", line 40, in handle
raw = file.read()
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 223: ordinal not in range(128)
here is the code:
with codecs.open(filename, 'r', encoding='utf-8') as file:
raw = file.read()
data = json.loads(raw)
Installations:
Windows 10, 64 bit.
Python 3.6.5
I am trying to execute pip install -r pyproj-1.9.6-cp36-cp36m-win_amd64.whl command.
However getting below error:
ERROR: Exception:
Traceback (most recent call last):
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in _main
status = self.run(options, args)
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\cli\req_command.py", line 185, in wrapper
return func(self, options, args)
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\commands\install.py", line 302, in run
check_supported_wheels=not options.target_dir,
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\cli\req_command.py", line 341, in get_requirements
finder=finder, options=options, session=session):
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_file.py", line 151, in parse_requirements
for parsed_line in parser.parse(filename, constraint):
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_file.py", line 330, in parse
for line in self._parse_and_recurse(filename, constraint):
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_file.py", line 335, in _parse_and_recurse
for line in self._parse_file(filename, constraint):
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_file.py", line 369, in _parse_file
filename, self._session, comes_from=self._comes_from
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\req\req_file.py", line 574, in get_file_content
content = auto_decode(f.read())
File "c:\users\sneka\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\utils\encoding.py", line 41, in auto_decode
locale.getpreferredencoding(False) or sys.getdefaultencoding(),
File "c:\users\sneka\appdata\local\programs\python\python36\lib\encodings\cp1252.py", line 15, in decode
return codecs.charmap_decode(input,errors,decoding_table)
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 118: character maps to <undefined>
I am new to python and not able to solve this error. Please help.
Remove -r. It should be pip install pyproj-1.9.6-cp36-cp36m-win_amd64.whl
I am trying to return a file in a StreamingHttpResponse from a class based view using Django rest framework. However I get a very cryptic error message with a stack trace that does not contain any references to my code:
16/Jun/2017 11:08:48] "GET /api/v1/models/49 HTTP/1.1" 200 0
Traceback (most recent call last):
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 179, in finish_response
for data in self.result:
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/util.py", line 30, in __next__
data = self.filelike.read(self.blksize)
File "/Users/jonathan/anaconda/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 12: ordinal not in range(128)
[...]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 141, in run
self.handle_error()
File "/Users/jonathan/anaconda/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 368, in handle_error
self.finish_response()
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "/Users/jonathan/anaconda/lib/python3.6/wsgiref/handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
My get method looks like this:
def get(self, request, pk, format=None):
"""
Get model by primary key (pk)
"""
try:
model = QSARModel.objects.get(pk=pk)
except Exception:
raise Http404
filename = model.pluginFileName
chunk_size = 8192
response = StreamingHttpResponse(
FileWrapper( open(filename), chunk_size ),
content_type = 'application/zip' )
return response
From googling a bit I get the feeling that this is related to ASCII / UTF8 encoding but I don't understand how that applies to my situation. I am dealing with a binary file. In fact it is a Java jar file but that should be pretty much a zip file as far as I understand. What is going on here and what am I doing wrong?
this is related to language translation. when non ascii filenames with the django storage system. So add following lines in your apache envvars
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
https://code.djangoproject.com/wiki/django_apache_and_mod_wsgi#AdditionalTweaking
I am having trouble with creating an executable for my python program with cx_freeze.I am on windows (XP) and my program uses Tkinter, Pygame (and random) and is coded in python 3.2. I have tried creating a distils and running from command prompt:
cxfreeze --target-dir dist
On both I get this error:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 117, in <module>
try: import pygame.display
File "ExtensionLoader_pygame_display.py", line 12, in <module>
File "ExtensionLoader_pygame_surface.py", line 12, in <module>
ImportError: No module named _view
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "BallGame.pyw", line 1, in <module>
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 118, in <module>
except (ImportError,IOError):display=MissingModule("display", geterror(), 1)
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 61, in __init__
self.warn()
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 85, in warn
warnings.warn(message, RuntimeWarning, level)
File "C:\Python32\lib\warnings.py", line 18, in showwarning
file.write(formatwarning(message, category, filename, lineno, line))
File "C:\Python32\lib\warnings.py", line 25, in formatwarning
line = linecache.getline(filename, lineno) if line is None else line
File "C:\Python32\lib\linecache.py", line 15, in getline
lines = getlines(filename, module_globals)
File "C:\Python32\lib\linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "C:\Python32\lib\linecache.py", line 127, in updatecache
lines = fp.readlines()
File "C:\Python32\lib\codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x90 in position 2: invalid s
tart byte
Please could you tell me how to fix it, or recommend a different piece of software to turn my python script into executables. Any help is greatly appreciated. Thanks in advance!
You need to run import pygame._view at the start of your script.