AttributeError: 'module' object has no attribute 'startfile'


Trying to run this <a href="https://www.daniweb.com/software-development/python/code/216929/saving-a-tkinter-canvas-drawing-python" rel="nofollow">program</a>, I got this error:

Traceback (most recent call last): File "piltk.py", line 84, in <module> os.startfile(filename) AttributeError: 'module' object has no attribute 'startfile'

How to fix this ?


On Linux you can use:

import subprocess, sys opener ="open" if sys.platform == "darwin" else "xdg-open" subprocess.call([opener, filename])

Adopted from <a href="https://stackoverflow.com/a/17317468/1079363" rel="nofollow">here</a>


Given that you are not running on Windows you cannot use os.startfile. If you want to launch another process you could use os.system or look at the subprocess module


  • How can I open a new browser tab with subprocess?
  • PyQt5: Using QtDesigner, how do you connect a signal with a slot/callable defined in a module
  • WPF XAML Button Click handler in InlineUIContainer problem
  • Readline feature in Directory Lister class
  • Transpose table then set and rename index
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • Meteor helpers not available in Angular template
  • Handling un-mapped Rest path
  • How reduce the height of an mschart by breaking up the y-axis
  • Accessing IRQ description array within a module and displaying action names
  • Perl system calls when running as another user using sudo
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Build own AppleScript numerical error handling
  • Websockets service method fails during R startup
  • Google cloud sdk not working when python points python3
  • Apache 2.4 - remove | delete | uninstall
  • AT Commands to Send SMS not working in Windows 8.1
  • Is there a mandatory requirement to switch app.yaml?
  • Cannot Parse HTML Data Using Android / JSOUP
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • using HTMLImports.whenReady not working in chrome
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • Understanding cpu registers
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How do I configure my settings file to work with unit tests?
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • Is it possible to post an object from jquery to bottle.py?
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • reshape alternating columns in less time and using less memory
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal