Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40497

Re: Python script not working on windows 7 but works fine on linux

Newsgroups comp.lang.python
Date 2013-03-04 18:58 -0800
References <5134f0d1$0$40360$4fafbaef@reader1.news.tin.it> <mailman.2854.1362424842.2939.python-list@python.org>
Subject Re: Python script not working on windows 7 but works fine on linux
From 88888 Dihedral <dihedral88888@googlemail.com>
Message-ID <mailman.2862.1362452346.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Tuesday, March 5, 2013 3:20:28 AM UTC+8, ian douglas wrote:
> On 03/04/2013 11:06 AM, io wrote:
> 
> > esclusioni_file = open('/home/io/btc_trading/exclusions.txt','r')
> 
> >
> 
> > Windows error :
> 
> >
> 
> > Traceback (most recent call last):
> 
> >    File "C:\btc_trading\scripts
> 
> > \import_json_2_csv_from_web_and_exclusions.py", line 10, in <module>
> 
> >      f = open("/home/io/btc_trading/markets.csv","wb")
> 
> > IOError: [Errno 2] No such file or directory: '/home/io/btc_trading/
> 
> > markets.csv'
> 
> 
> 
> The error tells you everything you need to know: the file system has no 
> 
> path/file called "/home/io/btc_trading/markets.csv"
> 
> 
> 
> I imagine your CSV file lives in a different location on your Windows 7 
> 
> system (which also uses back-slashes '\' instead of forward-slashes '/', 
> 
> so you'll need to maybe do a try/except around the open() call to open a 
> 
> Windows path like open("c:\\users\\io\\Documents\\markets.csv") or 
> 
> whatever. OR you'll need to do some OS detection ahead of time to set 
> 
> the file path properly.

Well, I'll suggest an old trick I did long time ago to resolve
the platform dependent problem in python.

Just write a generator as a buffered input method to work under some
file of some OS correctly first, then you can pass the generator which
is tested rigorously to act properly in the function or the object which will
use the generator to sip up the data to perform jobs.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python script not working on windows 7 but works fine on linux io <maroso@libero.it> - 2013-03-04 19:06 +0000
  Re: Python script not working on windows 7 but works fine on linux Christian Gollwitzer <auriocus@gmx.de> - 2013-03-04 20:20 +0100
    Re: Python script not working on windows 7 but works fine on linux io <maroso@libero.it> - 2013-03-04 19:58 +0000
  Re: Python script not working on windows 7 but works fine on linux ian douglas <iandouglas736@gmail.com> - 2013-03-04 11:20 -0800
    Re: Python script not working on windows 7 but works fine on linux io <maroso@libero.it> - 2013-03-04 19:59 +0000
      Re: Python script not working on windows 7 but works fine on linux Chris Angelico <rosuav@gmail.com> - 2013-03-05 07:56 +1100
    Re: Python script not working on windows 7 but works fine on linux Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-05 01:58 +0000
      Re: Python script not working on windows 7 but works fine on linux Andrew Berg <bahamutzero8825@gmail.com> - 2013-03-04 20:25 -0600
    Re: Python script not working on windows 7 but works fine on linux 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-04 18:58 -0800
    Re: Python script not working on windows 7 but works fine on linux 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-04 18:58 -0800
  Re: Python script not working on windows 7 but works fine on linux Wolfgang Strobl <news4@mystrobl.de> - 2013-03-04 20:30 +0100
  Re: Python script not working on windows 7 but works fine on linux Terry Reedy <tjreedy@udel.edu> - 2013-03-04 16:19 -0500

csiph-web