Re: Can I execute a python code written in Python 2.7 (using numpy and tensor flow executed in linux) in Winpython 3.6 on Windows?
On 4/17/2018 1:00 AM, Rishika Sen wrote: Here is the code that has been written in Python 2.7, numpy, tensorflow: https://drive.google.com/open?id=1JZe7wfRcdlEF6Z5C0ePBjtte_2L4Kk-7 One must 'sign in' to read this. Can you please let me know what changes I have to make to execute it on WinPython 3.6? Else, is there a version on Python 2.7 in Winpython? I have Winpython, I do not have Linux. If you has searched 'python tensorflow install' like I did you would have found https://www.tensorflow.org/install/install_windows and discovered that TensorFlow on Windows requires 64 bit 3.5 or 3.6. Learn to use Google, Bing, Yahoo, or whatever. I believe WinPython is the Python from python.org plus some extras. It may come with or have an easy option to install numpy (which is also available for 3.6). You may have to use 'py -m pip' instead of 'pip3' in the install instruction. Use the 3.6 2to3 tool to convert any custom 2.7 code to 3.6. See the manual. You may need to do additional conversion. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Import Impossibility
On 2018-04-17 08:35, 森平 直樹 wrote: > I installed by typing ‘py -m pip install openpyxl’. > > > > In my PC, python is installed in the following folder: > > C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32 > > But old version is left in the following folder: > > C:\Python27 > There you go. py.exe probably used Python 2.7 rather than Python 3.6. What Python version starts if you just run "py"? If it *is* Python 2.7 that's the default, you can use "py -3 -m pip" etc. Or, frankly, if you don't use Python 2.7, you might as well just uninstall it to save you the headaches. -- Thomas -- https://mail.python.org/mailman/listinfo/python-list
RE: Python Import Impossibility
Steven, When I installed ‘openpyxl’, there is no error message in the command prompt screen. So I think that my installation is successfully completed. I installed by typing ‘py -m install openpyxl’. In my PC, python is installed in the following folder: C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\DLLs C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\Doc C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\include C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\Lib C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\libs C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\Scripts C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\tcl C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32\Tools But old version is left in the following folder: C:\Python27\Lib\site-packages C:\Python27\Scripts Best Regards, - Naoki Morihira TEL: 01181-90-6460-6265 - 差出人: Python-list が Steven D'Aprano の代理で送信 送信日時: Friday, April 13, 2018 9:48:55 AM 宛先: python-list@python.org 件名: Re: Python Import Impossibility On Fri, 13 Apr 2018 12:48:55 +, ?? ?? wrote: > Hello, > > Could you tell me how to import the installed modules ? > > I have successfully installed openpyxl, How do you know it was successful? What did you do to install it? How many different Python installations do you have on your system? but When I executed ‘import > openpyxl’, The following message is displayed: > Traceback (most recent call last): > File "", line 1, in > import openpyxl > ModuleNotFoundError: No module named 'openpyxl' > > My folder is formed as follows: > [cid:image003.png@01D3D312.38C82830] There are no attachments permitted on this list. -- Steve -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Problem in extracting and saving multi-dimensional time series data from netcdf file to csv file
Hi All, I am using winpython spyder 3.6. I am trying to extract a variable with their time series values (daily from 1950 to 2004). The data structure is as follows: Dimensions: (bnds: 2, lat: 90, lon: 144, time: 20075) Coordinates: * lat (lat) float64 -89.0 -87.0 -85.0 -83.0 -81.0 -79.0 -77.0 ... * lon (lon) float64 1.25 3.75 6.25 8.75 11.25 13.75 16.25 18.75 ... * time(time) datetime64[ns] 1950-01-01T12:00:00 ... Dimensions without coordinates: bnds Data variables: time_bnds (time, bnds) datetime64[ns] ... lat_bnds(time, lat, bnds) float64 ... lon_bnds(time, lon, bnds) float64 ... clt (time, lat, lon) float32 ... Now I am extracting "clt" variable values based on my area of interest using lat/long boxes (latbounds = [ -13.0 , 31.0 ]# 22 grid numbers lonbounds = [ 89.75 , 151.25 ]#26 grid numbers My code is here: import netCDF4 import xarray as xr import numpy as np import csv import pandas as pd from pylab import * import datetime # NetCDF4-Python can read a remote OPeNDAP dataset or a local NetCDF file: nc = netCDF4.Dataset('clt_day_GFDL-CM3_historical_r1i1p1_19500101-20041231.nc.nc') nc.variables.keys() lat = nc.variables['lat'][:] lon = nc.variables['lon'][:] time_var = nc.variables['time'] dtime = netCDF4.num2date(time_var[:],time_var.units) lat_bnds, lon_bnds = [-13.0 , 31.0], [89.75 , 151.25] # determine what longitude convention is being used [-180,180], [0,360] print (lon.min(),lon.max()) print (lat.min(),lat.max()) # latitude lower and upper index latli = np.argmin( np.abs( lat - lat_bnds[0] ) ) latui = np.argmin( np.abs( lat - lat_bnds[1] ) ) # longitude lower and upper index lonli = np.argmin( np.abs( lon - lon_bnds[0] ) ) lonui = np.argmin( np.abs( lon - lon_bnds[1] ) ) print(lat) clt_subset = nc.variables['clt'][:,latli:latui , lonli:lonui] upto here I am able to extract the data but I am not able to save these values in csv file. I am also able to save values for one location but when I am going with multi-dimentional extracted values so it is giving an error when i am executing this: hs = clt_subset[istart:istop,latli:latui , lonli:lonui] tim = dtime[istart:istop] print(tim) # Create Pandas time series object ts = pd.Series(hs,index=tim,name=clt_subset) Error: - ts = pd.Series(hs,index=tim,name=clt_subset) Traceback (most recent call last): File "", line 1, in ts = pd.Series(hs,index=tim,name=clt_subset) File "C:\python3\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\core\series.py", line 264, in __init__ raise_cast_failure=True) File "C:\python3\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\core\series.py", line 3275, in _sanitize_array raise Exception('Data must be 1-dimensional') Exception: Data must be 1-dimensional Suggestions would be appreciated. Thanks Vishu -- https://mail.python.org/mailman/listinfo/python-list
How to save multi-dimentional array values into CSV/Test file
Hi All, I am using winpy 6.3 I have this array: code: clt_subset = nc.variables['clt'][:,latli:latui , lonli:lonui] print(clt_subset): [[[ 96.07967377 32.581317930.86773872 ..., 99.6185 99.7711 99.7711] [ 93.75789642 86.78536987 46.51786423 ..., 99.99756622 99.99769592 99.99931335] [ 99.19438171 99.71717834 97.34263611 ..., 99.99707794 99.99639893 99.93907928] ..., [ 7.657027241.1814307 4.02125835 ..., 39.58660126 37.71473694 42.10451508] [ 9.48283291 18.424989745.22411346 ..., 70.95629883 72.82741547 72.89440155] [ 33.297317546.50339508 88.39287567 ..., 98.50241089 98.47457123 91.32685089]] [[ 85.40306854 28.19069862 19.56433678 ..., 99.96898651 99.99860382 100.] [ 80.49911499 49.17562485 25.18140984 ..., 99.99198151 99.99337006 99.99979401] [ 99.982116791.44667816 78.83125305 ..., 99.99027252 99.99280548 99.5422] ..., so on.. print (clt_subset.shape) (20075, 22, 25) I am not able to save this array into csv file with time series using datetime function. The code is here: # 2. Specify the exact time period you want: start = datetime.datetime(1950,1,1,0,0,0) stop = datetime.datetime(2004,12,1,0,0,0) istart = netCDF4.date2index(start,time_var,select='nearest') istop = netCDF4.date2index(stop,time_var,select='nearest') print (istart,istop) hs = clt_subset[istart:istop,latli:latui , lonli:lonui] tim = dtime[istart:istop] ts = pd.Series(hs,index=tim,name=clt_subset) ts.to_csv('time_series_from_netcdf.csv') while executing this, saying: Error- File "C:\python3\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\core\series.py", line 3275, in _sanitize_array raise Exception('Data must be 1-dimensional') Exception: Data must be 1-dimensional -- https://mail.python.org/mailman/listinfo/python-list
Re: How to save xarray data to csv
On 17/04/18 03:25, shalu.ash...@gmail.com wrote: My question is how can i save multi-dimentional (3d: time series values, lat, long) data (xarrays) into csv. What do you want each line of the CSV file to look like? That's the key question. Once you know that you can arrange your data into a (one dimensional) list of that form and then write it out. Since I have exactly no idea what netCDF4.Dataset() does (and less interest in finding out), I can't offer much advice. The slicing that you're doing looks like some weird limiting selection, but there must be some way of iterating through entries, surely? -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
tkinter frame not expanding to fit window?
I've just started working through the tutorial here → http:// www.tkdocs.com/tutorial/firstexample.html and I already hit some behavior that I don't understand. The frame doesn't expand when I resize the window! The tutorial says these lines should do it: mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) As an experiment I tried commenting those lines out, just to see if anything would change, and nothing did. So it seems they aren't working for me, but I don't know why. Any suggestions? This is all running on Ubuntu MATE 17.10 and tk8.6. -- https://mail.python.org/mailman/listinfo/python-list
Most pythonic way to implement byte stuffing algorithm
I posted this on SO, but… yeah… I'm doing some serial protocol stuff and want to implement a basic byte stuffing algorithm in python. Though really what this really generalizes to is “what is the most pythonic way to transform one sequence of bytes where some bytes are passed through 1:1, but others are transformed to longer subsequences of bytes?” I’m pretty sure this rules out the use of transform() which expects a 1:1 mapping. So far, I've come with 5 different approaches, and each of them has something I don't like about it: 1 Via Generator def stuff1(bits): for byte in bits: if byte in _EscapeCodes: yield PacketCode.Escape yield byte ^ 0xFF else: yield byte This may be my favorite, but maybe just because I'm kind of fascinated by yield based generators. I worried that the generator would make it slow, but it's actually the second fastest of the bunch. 2 Simply bytes() def stuff2(bits): result = bytes() for byte in bits: if byte in _EscapeCodes: result += bytes([PacketCode.Escape, byte ^ 0xFF]) else: result += bytes([byte]) return result Constantly has to create single element arrays just to throw them out because I'm not aware of any "copy with one additional element" operation. It ties for the slowest of the bunch. 3 Use bytearray() def stuff3(bits): result = bytearray() for byte in bits: if byte in _EscapeCodes: result.append(PacketCode.Escape) result.append(byte ^ 0xFF) else: result.append(byte) return result Seems better than the direct bytes() approach. Actually slower than the yield generator and can do one byte at a time (instead of needing intermediate 1 element collections). But it feels brutish. It's middle of the pack performance. 4 BytesIO() def stuff4(bits): bio = BytesIO() for byte in bits: if byte in _EscapeCodes: bio.write(bytes([PacketCode.Escape, byte ^ 0xFF])) else: bio.write(bytes([byte])) return bio.getbuffer() I like the stream based approach here. But it is annoying that there doesn't seem to be something like a write1() API that could just add 1 byte, so I have to make those intermediate bytes again. If there was a "write single byte", I'd like this one. It ties for slowest. 5 Use replace() def stuff5(bits): escapeStuffed = bytes(bits).replace(bytes([PacketCode.Escape]), bytes([PacketCode.Escape, PacketCode.Escape ^ 0xFF])) stopStuffed= escapeStuffed.replace(bytes([PacketCode.Stop]), bytes([PacketCode.Escape, PacketCode.Stop ^ 0xFF])) return stopStuffed.replace(bytes([PacketCode.Start]), bytes([PacketCode.Escape, PacketCode.Start ^ 0xFF])) This is the fastest. But I don't like the way the code reads and the intermediate sweeps. -- https://mail.python.org/mailman/listinfo/python-list
RE: Python Import Impossibility
Thomas, I installed by typing the following command in the MS-Windows command prompt screen. ‘py -m pip install openpyxl’. Best Regards, - Naoki Morihira TEL: 01181-90-6460-6265 - 差出人: Python-list が Thomas Jollans の代理で送信 送信日時: Friday, April 13, 2018 9:38:15 AM 宛先: python-list@python.org 件名: Re: Python Import Impossibility On 13/04/18 14:48, ?? ?? wrote: > Hello, > > Could you tell me how to import the installed modules ? > > I have successfully installed openpyxl, but > When I executed ‘import openpyxl’, > The following message is displayed: > Traceback (most recent call last): > File "", line 1, in > import openpyxl > ModuleNotFoundError: No module named 'openpyxl' > > My folder is formed as follows: > [cid:image003.png@01D3D312.38C82830] Is it possible that you installed the module in the wrong Python installation? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Most pythonic way to implement byte stuffing algorithm
On 2018-04-17, Travis Griggs wrote: > I posted this on SO, but… yeah… > > I'm doing some serial protocol stuff and want to implement a basic > byte stuffing algorithm in python. Though really what this really > generalizes to is “what is the most pythonic way to transform one > sequence of bytes where some bytes are passed through 1:1, but > others are transformed to longer subsequences of bytes?” I’m pretty > sure this rules out the use of transform() which expects a 1:1 > mapping. > > > So far, I've come with 5 different approaches, and each of them has something > I don't like about it: > > 1 Via Generator > > def stuff1(bits): > for byte in bits: > if byte in _EscapeCodes: > yield PacketCode.Escape > yield byte ^ 0xFF > else: > yield byte > > This may be my favorite, but maybe just because I'm kind of > fascinated by yield based generators. I worried that the generator > would make it slow, but it's actually the second fastest of the > bunch. I find that the most readible, and would certainly get my vote -- even if it was the slowest (unless it was so slow as to be a problem). [...] > def stuff5(bits): > escapeStuffed = bytes(bits).replace(bytes([PacketCode.Escape]), > bytes([PacketCode.Escape, PacketCode.Escape ^ 0xFF])) > stopStuffed= escapeStuffed.replace(bytes([PacketCode.Stop]), > bytes([PacketCode.Escape, PacketCode.Stop ^ 0xFF])) > return stopStuffed.replace(bytes([PacketCode.Start]), > bytes([PacketCode.Escape, PacketCode.Start ^ 0xFF])) > > This is the fastest. But I don't like the way the code reads and the > intermediate sweeps. Yow, that's ugly -- I don't think I'd be able to tell you what it actually does without actually running it. If speed is that important, I might just write a function in C and call it with ctypes. :) -- Grant Edwards grant.b.edwardsYow! HAIR TONICS, please!! at gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Python Import Impossibility
Hello, Could you tell me how to import the installed modules ? I have successfully installed openpyxl, but When I executed ‘import openpyxl’, The following message is displayed: Traceback (most recent call last): File "", line 1, in import openpyxl ModuleNotFoundError: No module named 'openpyxl' My folder is formed as follows: [cid:image003.png@01D3D371.38FF7FB0] Best Regards, - Naoki Morihira TEL: 01181-90-6460-6265 - -- https://mail.python.org/mailman/listinfo/python-list
Re: Most pythonic way to implement byte stuffing algorithm
On 2018-04-17 17:02, Travis Griggs wrote: I posted this on SO, but… yeah… I'm doing some serial protocol stuff and want to implement a basic byte stuffing algorithm in python. Though really what this really generalizes to is “what is the most pythonic way to transform one sequence of bytes where some bytes are passed through 1:1, but others are transformed to longer subsequences of bytes?” I’m pretty sure this rules out the use of transform() which expects a 1:1 mapping. [snip] There are only 256 possible input bytes, so just put them into a dict and look them up. -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter frame not expanding to fit window?
Zobeid Zuma wrote: > I've just started working through the tutorial here → http:// > www.tkdocs.com/tutorial/firstexample.html and I already hit some behavior > that I don't understand. The frame doesn't expand when I resize the > window! The tutorial says these lines should do it: > > mainframe.columnconfigure(0, weight=1) > mainframe.rowconfigure(0, weight=1) > > As an experiment I tried commenting those lines out, just to see if > anything would change, and nothing did. So it seems they aren't working > for me, but I don't know why. Any suggestions? > > This is all running on Ubuntu MATE 17.10 and tk8.6. Here is a minimalistic example with a red Frame in a blue window: import tkinter as tk root = tk.Tk() root["background"] = "blue" frame = tk.Frame(root, background="red") frame.grid(row=0, column=0, sticky=tk.NSEW) root.rowconfigure(0, weight=1) root.columnconfigure(0, weight=1) root.mainloop() When you run it as is you should see the red frame. When you remove the lines root.rowconfigure(0, weight=1) root.columnconfigure(0, weight=1) you should see the blue window instead. When you put those lines back in, but change the line frame.grid(row=0, column=0, sticky=tk.NSEW) to frame.grid(row=0, column=0) you will also see blue. So my crystal ball says that in the code that you don't show you forgot to make the Frame "sticky". -- https://mail.python.org/mailman/listinfo/python-list
Re: Most pythonic way to implement byte stuffing algorithm
> On Apr 17, 2018, at 11:15 AM, MRAB wrote: > > On 2018-04-17 17:02, Travis Griggs wrote: >> I posted this on SO, but… yeah… >> I'm doing some serial protocol stuff and want to implement a basic byte >> stuffing algorithm in python. Though really what this really generalizes to >> is “what is the most pythonic way to transform one sequence of bytes where >> some bytes are passed through 1:1, but others are transformed to longer >> subsequences of bytes?” I’m pretty sure this rules out the use of >> transform() which expects a 1:1 mapping. > [snip] > There are only 256 possible input bytes, so just put them into a dict and > look them up. > -- > https://mail.python.org/mailman/listinfo/python-list So something like this? LUT = list(bytes([x]) for x in range(256)) LUT[PacketCode.Escape] = bytes([PacketCode.Escape, PacketCode.Escape ^ 0xFF]) LUT[PacketCode.Start] = bytes([PacketCode.Escape, PacketCode.Start ^ 0xFF]) LUT[PacketCode.Stop] = bytes([PacketCode.Escape, PacketCode.Stop ^ 0xFF]) def stuff6(bits): return b''.join(LUT[x] for x in bits) -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Python Import Impossibility
Given that the list does not allow pictures, would it make sense to have the software that strips the pictures also send an e-mail to the picture sender indicating that pictures are disallowed? I see a lot of people responding individually saying that images are stripped. It's looking like a bit of a traffic increaser. In a more draconian world, we could even bounce such messages. -- Forwarded message -- From: ?? ?? Date: Mon, Apr 16, 2018 at 8:19 PM Subject: Python Import Impossibility To: "Python-list@python.org" Hello, Could you tell me how to import the installed modules ? I have successfully installed openpyxl, but When I executed ‘import openpyxl’, The following message is displayed: Traceback (most recent call last): File "", line 1, in import openpyxl ModuleNotFoundError: No module named 'openpyxl' My folder is formed as follows: [cid:image003.png@01D3D371.38FF7FB0] Best Regards, - Naoki Morihira TEL: 01181-90-6460-6265 - -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Newbie ARGPARSE question
I just discovered ARGPARSE 5 minutes ago and cannot figure this one out: What does the Parser.add_argument() call have to look like when I need an option 'add' that requires the mandatory parameters 'type' (string), 'size' (int), 'sid' (string) and must also handle the optional parameters 'comment' (string) and 'auto-start' (bool, defaults to TRUE). Thanks to all helping me preserve my sanity! -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Python Import Impossibility
On 4/17/2018 5:06 PM, Dan Stromberg wrote: Given that the list does not allow pictures, would it make sense to have the software that strips the pictures also send an e-mail to the picture sender indicating that pictures are disallowed? I see a lot of people responding individually saying that images are stripped. It's looking like a bit of a traffic increaser. My impression is that attachments are more common than 20 years ago. In a more draconian world, we could even bounce such messages. If Tim Golden does not reply to this, send suggestion to python-list-owner at python.org -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
W dniu sobota, 27 stycznia 2018 16:59:50 UTC+1 użytkownik larry@gmail.com napisał: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ > errread, errwrite) > File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory > > Anyone have any clue as to what file it's complaining about? Or how I > can debug this further? Larry, I have exactly the same problem. I'd like to run a script and from normal user it works, and from cron doesn't. In sumarry I was googled to find information how to set two or more env. variables and pass them to subprocess.open. I also try to read $HOME/.profile where usually these env. var. are setting. Have anyone see any example how to do it? Please let me know. Regards, Daniel -- https://mail.python.org/mailman/listinfo/python-list
ARGPARSE Newbie question
I'd like to create a script that handles a number of verbs with mandatory and /or optional parameters like listed in the table below. Can ARGPARSE do this and how? Thanks for all help! Script VerbMandatory parameters Optional parameters -- myprog.py list--- verbose myprog.py add sid(string), type (string), memory (int) comment (string), autostart (bool, default=TRUE) myprog.py memory sid (string), memory (integer) myprog.py comment sid(string), comment (string) myprog.py restore sid(string), srcpath (string) myprog.py backup sid(string), dstpath(string) myprog.py remove sid (string) -- https://mail.python.org/mailman/listinfo/python-list
Re: ARGPARSE Newbie question
On Tuesday, April 17, 2018 at 7:09:45 PM UTC-5, TUA wrote: > I'd like to create a script that handles a number of verbs with mandatory and > /or optional parameters like listed in the table below. > > Can ARGPARSE do this and how? > > Thanks for all help! > > > > > > Script VerbMandatory parameters Optional > parameters > -- > myprog.py list--- verbose > > myprog.py add sid(string), type (string), memory (int) comment > (string), autostart (bool, default=TRUE) > > myprog.py memory sid (string), memory (integer) > > myprog.py comment sid(string), comment (string) > > myprog.py restore sid(string), srcpath (string) > > myprog.py backup sid(string), dstpath(string) > > myprog.py remove sid (string) you can use subparsers for this. The syntax goes something like this: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subparser_name') list_parser = subparsers.add_parser("list", help="help for list") list_parse.add_argument("-v", "--verbose", help="show verbose output", action="store_true") add_parser = subparsers.add_parser("add", help="help for add") add.add_argument("sid", type=str, help="help for sid") ... etc. see the documentation on argparse for more on this. -- https://mail.python.org/mailman/listinfo/python-list
Re: ARGPARSE Newbie question
Thanks for the pointers! -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
On Tue, Apr 17, 2018 at 4:11 PM, wrote: > W dniu sobota, 27 stycznia 2018 16:59:50 UTC+1 użytkownik larry@gmail.com > napisał: >> I have a script that does this: >> >> subprocess.Popen(['service', 'some_service', 'status'], >> stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >> >> When I run it from the command line it works fine. When I run it from >> cron I get: >> >> subprocess.Popen(['service', 'some_service', 'status'], >> stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >> File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ >> errread, errwrite) >> File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child >> raise child_exception >> OSError: [Errno 2] No such file or directory >> >> Anyone have any clue as to what file it's complaining about? Or how I >> can debug this further? > > Larry, I have exactly the same problem. I'd like to run a script and from > normal user it works, and from cron doesn't. > > In sumarry I was googled to find information how to set two or more env. > variables and pass them to subprocess.open. I also try to read $HOME/.profile > where usually these env. var. are setting. Have anyone see any example how > to do it? Please let me know. Regards, Daniel Is service on your $PATH in the cronjob? What if you set the variables you need in the program, and test it with "env - myscript" in a login shell, to run myscript with an empty environment? This tends to make under cron and not under cron more similar. HTH -- https://mail.python.org/mailman/listinfo/python-list
RE: Python Import Impossibility
Thomas, I deleted ‘C:\Python27’, and executed in Windows Command prompt screen, ‘C:Users/N.Morihira>py -m install openpyxl’, But the following message was displayed * Requirement already satisfied: openpyxl in c:\users\n.morihira\anaconda3\lib\site-packages * Requirement already satisfied: jdcal in c:\users\n.morihira\anaconda3\lib\site-packages (from openpyxl) * Requirement already satisfied: et_xmlfile in c:\users\n.morihira\anaconda3\lib\site-packages (from openpyxl), And it also displays the following message in Python3.6.4 Shell screen. >>> import openpyxl Traceback (most recent call last): File "", line 1, in import openpyxl ModuleNotFoundError: No module named 'openpyxl' Best Regards, - Naoki Morihira TEL: 01181-90-6460-6265 - 差出人: Python-list が Thomas Jollans の代理で送信 送信日時: Tuesday, April 17, 2018 1:12:48 AM 宛先: python-list@python.org 件名: Re: Python Import Impossibility On 2018-04-17 08:35, 森平 直樹 wrote: > I installed by typing ‘py -m pip install openpyxl’. > > > > In my PC, python is installed in the following folder: > > C:\Users\N.Morihira\AppData\Local\Programs\Python\Python36-32 > > But old version is left in the following folder: > > C:\Python27 > There you go. py.exe probably used Python 2.7 rather than Python 3.6. What Python version starts if you just run "py"? If it *is* Python 2.7 that's the default, you can use "py -3 -m pip" etc. Or, frankly, if you don't use Python 2.7, you might as well just uninstall it to save you the headaches. -- Thomas -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Finding set difference between ranges
Hello all, I have 3 continuous (steps of 1) ranges a,a1,a2. All of them sorted. I am performing the following operations on them a = a.difference (a1) a = a.difference(a2) Now, this doesn't seem to make use of the fact that 1. They are sorted 2. They increase in steps of 1 . Could someone suggest a better way of doing this to make these operations more efficient? Thank you, Tejaswi D Prakash -- https://mail.python.org/mailman/listinfo/python-list