Non-ASCII character '\ x90' executing pserve on windows inside virtualenv

Question: How can I solve the no-ascii character error running pserve on virtualenv in windows?

Description: I am trying to execute pserve (pyllons / pyramid development web server) inside virtualenv on windows. This is a new installation, so it may be related to versions.

Problem: When virtualenv is activated, run pserve config.ini throw error: SyntaxError: Non-ASCII character '\x90' in file C:\PATH_TO_MY_ENV_HOME\env\Scripts\pserve.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details SyntaxError: Non-ASCII character '\x90' in file C:\PATH_TO_MY_ENV_HOME\env\Scripts\pserve.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details .

Command line:

 pserve development.ini --reload 

Notes:

  • this error occurs when you have a character file that does not match the current encoding of the file, so you can add instructions to set the correct encoding on the threshold of a python script.
  • this can happen if the called target has an exe extension in some cases and a script that causes it to add exe to the end. Thus, python runtime causes this error, so the exe file cannot be called as a script, but simply called without adding sufix.
  • The path to the executable file does not contain special characters.

Tests completed:

  • Remove the exe extension from pserve. Not working: command message not recognized.
  • Call pserve- script.py instead of pserve (full path tried too). It did not work: to do nothing and returns nothing.
  • Added "- * - encoding: utf-8" at the beginning of pserve- script.py. This is the same message.
  • Delete exe extenstion from python.exe (tried the full path too). Did not work: "could not create the process."

Environment:

  • Windows 10 1607 build 14393.447
  • Python Version: Anaconda2, Python 2.7.11
  • Version for the pyramid: pyramid 1.7.3
  • Virtual env: 15.1.0

DECISION:

Removing and installing again solved the problem for me.

+7
python windows pyramid virtualenv
source share
4 answers

instead of encoding I just use coding (and it seems that -*- not required). Almost every python script I wrote starts with:

 #coding: utf-8 

I am using Python 2.7.10 on Windows 10

0
source share

In fact, I have no answer, since I am not using either Pyramid or Windows. However, this has been noticed by several people and may be due to the fact that python.exe used to execute pserve.exe , which will not work as an executable file, not a Python program.

Here are some links that can move forward - we recommend that you join the Google group, as it has a more concentrated experience with Pyramid:

One specific idea is to provide the pserve.py not pserve.exe and use python pserve.py to run it. If the calling script has limitations, create a run-pserve.bat batch file to call Python and test it outside the calling script.

Alternatively, you can use the pre-configured Linux virtual machine on Windows. Or in Windows 10 there is a good “Bash for Windows” aka “Windows Subsystem for Linux”, which is really full Ubuntu Linux. I would think that any of them would make it very easy to develop than Windows.

0
source share

Assuming your virtualenv is in the venv directory

Use this:

 python venv/Lib/site-packages/pyramid/scripts/pserve.py some-ini-config.ini --reload 
0
source share

This error message contains a suggestion and reads:

Syntax error: non-ASCII character '\ x90' in the file /path/to/file in line #lineno , but the encoding is not declared; see http://python.org/dev/peps/pep-0263/ for more details

The greasy part is where the sentence is. This PEP is very simple, and the solution is to simply define the encoding for your source file. Most likely you will have

 #!/usr/bin/env python # coding=utf-8 

The interpreter string is optional, but the encoding can be specified second if you have an interpreter string, or first if you don't

Set the encoding depending on your character sets. utf-8 should work in most cases, or you may need other encodings.

0
source share

All Articles