Skip to content
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
Closed

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

pzwang opened this issue Jul 30, 2014 · 5 comments
Labels
Milestone

Comments

@pzwang
Copy link

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 proc.name is a string, not a function (in is_excel_running()) proc.name is a string, not a function (in is_excel_running()) Jul 30, 2014
@fzumstein
Copy link
Member

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
Copy link
Member

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
Copy link
Author

pzwang commented Jul 30, 2014

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

@fzumstein
Copy link
Member

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

@pzwang
Copy link
Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants