473,614 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ValueError: invalid \x escape

I wrote a python code in linux text pad and copied to thumb drive and
try to ran the file by changing the path to windows:

sys.path = sys.path + ['D:\Python24\Li b\site-packages\mycode]

I get the following error:

ValueError: invalid \x escape

I am pretty sure this problem is due some kind of linux end of line
markers or escape characters that windows os doesn't understand. Is
there a way to fix this?

Nov 2 '07 #1
1 19243
crybaby wrote:
I wrote a python code in linux text pad and copied to thumb drive and
try to ran the file by changing the path to windows:

sys.path = sys.path + ['D:\Python24\Li b\site-packages\mycode]

I get the following error:

ValueError: invalid \x escape

I am pretty sure this problem is due some kind of linux end of line
markers or escape characters that windows os doesn't understand. Is
there a way to fix this?

You have two errors in your code. The first is that you didn't close
your quotes. However, that wouldn't cause a value error, so you
probably introduced that one in your email. The other is that you
haven't escaped your backslashes. Python, unlike many other scripting
languages, does not distinguish between single and double quotes (except
insofar as there may be single or double quotes within the string, of
course), so python sees a \P, a \L a \s, and a \m in your string. There
are two ways to solve this:

1) Use a raw string: r'D:\Python24\L ib'
2) Escape your backslashes: 'D:\\Python24\\ Lib'

I assume the real value of 'mycode' has an x immediately after a \, right?

Cheers,
Cliff
P.S. I just got my crystal ball back from the cleaners, so I can guess
some of what you haven't told us, but in the future, make sure the code
you post exhibits the problem you see. Use copy and paste instead of
retyping, and if you change the code, make sure the changed code still
exhibits the same problems.
Nov 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5043
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works, sometimes not. From mysql: mysql> show databases; +-----------+ | Database |
12
4230
by: Aki Niimura | last post by:
Hello everyone, I started to use pickle to store the latest user settings for the tool I wrote. It writes out a pickled text file when it terminates and it restores the settings when it starts. It worked very nicely. However, I got a ValueError when I started the tool from Unix when I previously used the tool from Windows.
1
2310
by: Martin MOKREJ© | last post by:
Hi, is this a bug or "feature" that I have to use float() to make int() autoconvert from it? $ python Python 2.3.4 (#1, Feb 14 2005, 10:00:27) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 1 >>> "%5.10e" % (a)
3
4610
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that the user has to use my New Record button. When you click the New Record button, the form presents a new record for editing. My client wants to use the Escape key to cancel changes to new or existing records. On existing records, Access already...
0
1434
by: philip20060308 | last post by:
Hi all, Has anyone ever seen Python 2.4.1's httplib choke when reading chunked content? I'm using it via urrlib2, and I ran into a particular server that returns something that httplib doesn't expect. Specifically, in the code below where the error occurs, line == ''. Python 2.4.1 (#2, Oct 12 2005, 01:36:32) 20050518] on freebsd6 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib2
1
17210
by: alain MONTMORY | last post by:
Hello everybody, I am a newbie to python so I hope I am at the right place to expose my problem..... :-http://www.python.org/doc/2.4.2/ext/pure-embedding.html 5.3 Pure Embedding I download the code example from http://www.python.org/doc/2.4.2/ext/run-func.txt I call the file "TestOfficiel.c" and I compile it with : gcc -g -I/usr/include/python2.3/ TestOfficiel.c -o TestOfficiel -lpython2.3 -ldl all is OK (or seems to be...).
2
2335
by: abcd | last post by:
I have the following code which is sent over the wire as a string... from time import time class Foo: def go(self): print "Time:", time() I get this code and store it as, "data"
1
3169
Eclipse
by: Eclipse | last post by:
G'day all In the code below I am trying to catch an error thrown if i enter any other value than an integer. (I used the string 'six' and the float '1.5') The error thrown in the command window by the code is: Traceback (most recent call last): File "C:\Documents and Settings\Smythville\My Documents\Python\Stuff\Ch4\ex1-6.py", line 59, in <module> a = int(raw_input("\nTry a number!")) ValueError: invalid literal for int() with...
11
12324
by: davidj411 | last post by:
i am parsing a cell phone bill to get a list of all numbers and the total talktime spend on each number. i already have a unique list of the phone numbers. now i must go through the list of numbers and add up the totals for each number. on the bill, each line has a few fields,one field containing the phone number, another field containing the number of minutes on that call. the bill is comma delimited.
0
8130
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8627
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8579
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8433
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7093
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4052
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.