New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc.name is a string, not a function (in is_excel_running()) #48

Closed
pzwang opened this Issue Jul 30, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@pzwang

pzwang commented Jul 30, 2014

Just following the example in the README. Changing proc.name() to proc.name fixes the problem. Python 2.7 (Anaconda) on OS X.

 In [1]: from xlwings import Workbook, Range, Chart
 In [2]: wb=Workbook()
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call last)
 <ipython-input-2-fa7edd33f875> in <module>()
 ----> 1 wb=Workbook()

 /Users/pwang/anaconda/lib/python2.7/site-packages/xlwings/main.pyc in __init__(self, fullname)
      68         else:
      69             # Open Excel if necessary and create a new workbook
 ---> 70             self.xl_app, self.xl_workbook = xlplatform.new_workbook()
      71
      72         self.name = xlplatform.get_workbook_name(self.xl_workbook)

 /Users/pwang/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.pyc in new_workbook()
      73
      74 def new_workbook():
 ---> 75     is_running = is_excel_running()
      76
      77     xl_app = app('Microsoft Excel')

 /Users/pwang/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.pyc in is_excel_running()
      30 def is_excel_running():
      31     for proc in psutil.process_iter():
 ---> 32         if proc.name() == 'Microsoft Excel':
      33             return True
      34     return False

 TypeError: 'str' object is not callable

@pzwang pzwang changed the title from `proc.name` is a string, not a function (in `is_excel_running()`) to proc.name is a string, not a function (in is_excel_running()) Jul 30, 2014

@fzumstein

This comment has been minimized.

Member

fzumstein commented Jul 30, 2014

hm - what version of psutil are you using? According to the docs it's a method. Also, this is what I get during debugging:

>>> proc.name
Out[1]: <bound method Process.name of <psutil.Process(pid=0, name='kernel_task') at 4419146768>>
>>> proc.name()
Out[2]: 'kernel_task'
>>> import psutil
>>> psutil.__version__
Out[4]: '2.1.1'
@fzumstein

This comment has been minimized.

Member

fzumstein commented Jul 30, 2014

According to here, this error happens with psutil 1.2.1. What would you say makes more sense, require a minimum psutil version in setup.py or wrap it into a try/except TypeError block?

@pzwang

This comment has been minimized.

pzwang commented Jul 30, 2014

Ha, I'm using v0.6.1. I'd say to add a minimum version requirement...

@fzumstein

This comment has been minimized.

Member

fzumstein commented Jul 30, 2014

Cool thanks! In the meantime, I would recommend conda update psutil;-)

@pzwang

This comment has been minimized.

pzwang commented Jul 30, 2014

Yep, worked like a charm. :-)

@fzumstein fzumstein added the bug label Sep 13, 2014

@fzumstein fzumstein added this to the v0.2.2 milestone Sep 13, 2014

@fzumstein fzumstein closed this in a47167d Sep 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment