-
Notifications
You must be signed in to change notification settings - Fork 491
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
Exception: Invalid field name: Date! friends_followers__calculate_avg_influence_of_followers.py #30
Comments
Can you post a full stack trace? Thanks. |
Hi Matthew, Thank you for your reply. Love your book btw. I added the trackback code and I saw in the error that I forgot to easy_install the psyco library. Searching for psyco The path does no longer exist: http://wyvern.cs.uni-duesseldorf.de/psyco/psyco-snapshot.tar.gz, so manually installed the .exe for python2.5 on my windows 7 64bit (on which I have python2.7 installed) - I got the file from http://psyco.sourceforge.net/psycoguide/sources.html at the following link http://sourceforge.net/project/showfiles.php?group_id=41036 . Now I get the following error on my PC -I guess that psyco is not compatible with version 2.7: I did a search on this issue, and found that it psyco is no longer supported on the new version of python, if i am correct, and an alternative is pypy: http://pypy.org/ If you can help me make this code work on python 2.7 on either my ubuntu or pc that would be great. Of course a solution for both platforms would be fantastic :) Thank you for your time, Const From: Matthew A. Russell reply@reply.github.com Can you post a full stack trace? Thanks. Reply to this email directly or view it on GitHub: |
Sorry for the follow up, I just realized that your code uses psyco when available. I adjusted the code with the following addition in bold, to trace this - not sure if this is correct way, sorry I am a Python newbie: fields = ['Date', 'Count'] So by bypassing psyco, I get the same error below: C:\Users\ccc\Dropbox\Documents\const\class\python_code>friends_followers__calculate_avg_influence_of_followers.py constantinz Traceback (most recent call last): From: Matthew A. Russell reply@reply.github.com Can you post a full stack trace? Thanks. Reply to this email directly or view it on GitHub: |
I think the problem is with the PrettyTable code, since when I comment out the code of pretty table and just do a print the code works. Let me know what you find out. Below is my code that works, without PrettyTable:
... |
Based on what I am seeing from your output, my best guess is that something may be wrong with how psyco is trying to optimize code within the PrettyTable package. If you were to remove the try/catch block entirely and execute calculate() directly without trying to do anything at all with psyco (namely, bind it to the calculate() function), the code would also work. Would be interested to know if this works out for you. (I seriously doubt that PrettyTable is doing anything to cause an error, and I didn't see anything in your stack traces that suggested that it was at fault. At any rate, I'm gal that this is working for you.) |
Thanks for the quick reply. Fyi, I did remove the psyco completely and I got the same error, until I commented out the prettytable code, and added the print statements, like I showed you on the code above. What is weird is that prettytable works when I compile a simple app as follow, but not with your code :(
Does you code compile on your machine? Reason I ask is that the code below is not liked on either Win7 or Ubuntu:
Could it be something with the syntax because of older python version? |
The code that you provided does run just fine on my machine with prettytable version 0.5 (as shown by printing out pretty table.__file__ ) with Python 2.6, but it could be entirely possible that prettytable has changed its constructor since then if you're running a newer version, which seems to be 0.6.1 per PyPi http://pypi.python.org/pypi/PrettyTable. The change should be pretty easy to incorporate if the constructor is different in a newer version. This is another case in point for me needing to get a VM setup with the right version of the code checked out on it. As these OSS libs change, the code is increasingly breaking. Lots of these scripts use pretty table, so I might have to do a larger review of the code and see what else is broken at this point. I appreciate you bringing this to light. |
Matthew, Great work on the book. I ran into the same issue in Example 6.2 (linkedin_analyze_titles.py). With some investigation, it appears that PrettyTable 0.6.1. broke compatibility with 0.5. This works in Python 2.6: pt = PrettyTable(['Token', 'Freq']) Check it out. Stewart |
I really appreciate the confirmation/follow up on this. I'll make a note to go through and patch the scripts that use the prettytable package very soon. In the meanwhile, patches would be welcome (for anybody who wants to take a crack at these relatively simple patches during the course of their own work.) I'll follow up here one last time once it's all patched. |
Hi Matthew and others, Here's my patch, which is helpful for those who might not know how to integrate Stewart's lines. Can just be subbed line-for-line from 49-58 and works with PrettyTable 0.6.1/Python 2.7.3. fields = ['Date', 'Count'] for (user, freq) in reversed([(user['screen_name'], k) for k in keys[-10:] print pt.get_string() Thanks and great work on this book. |
Hi Matthew, I got the same error "Invalid Field Name: Company" error for Example 6-1 (linkedin_analyze_companies.py) and I'm not able to resolve this error despite trying the different approaches mentioned here. Can I paste my output here - since it's the same type of error, only for a different script - to get your help on this? This is my first time posting on Github so, please do guide me if that's not the right way of opening an issue here! Thanks, Sid |
Sure, feel free to post in your script, but more importantly, can you also include your version of PrettyTable as well? AFAICT, that's going to be the real issue and any fix is going to come down to being able to tweak the code to work as robbfitzsimmons describes. Glad to help though if you need a hand, so let me know if you haven't gotten this to work yet. |
Matthew, Thank you for getting back to me! I appreciate it a lot. Quick notes:
In [15]: run linkedin_analyze_companies.py linkedin_connections_export_microsoft_outlook.csvException Traceback (most recent call last) /Users/Menon/Documents/Python Stuff/PyScripts/Textbook/linkedin_analyze_companies.py in () /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/prettytable.pyc in init(self, field_names, encoding, **kwargs) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/prettytable.pyc in _validate_option(self, option, val) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/prettytable.pyc in _validate_all_field_names(self, name, val) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/prettytable.pyc in _validate_field_name(self, name, val) Exception: Invalid field name: Company! ------------------------------------------------------------------------- END -------------------------------------------------------------------------------- Does this help identify the issue? |
The following code for
|
I believe the PrettyTable issues have been fixed with recent changesets, so I'm going to close this. |
Can you tell me what versions of modules I need to make this work? I upgraded to prettytable 0.7.2 and I still get this error: |
Hmm. That version should work, though I think the version I used is 0.7.1. Can you tell me the name of the script where you are seeing this error. It could be possible that I missed one of the scripts when I was going through and upgrading the code to work with the new prettytable syntax |
I am using prettytable 0.7.2 and I get the following when running the Example 3-14 threading code (https://github.com/ptwobrussell/Mining-the-Social-Web/blob/master/python_code/mailboxes__threading.py) Traceback (most recent call last): Based on previous postings in this thread, I changed the code as follows: fields = ['Thread Id', 'Thread Length'] for stat in stats: #pt.printt() |
I get an Exception: Invalid field name: Date!
when I run: friends_followers__calculate_avg_influence_of_followers.py
It seems it does not like the fields at the line of code:
Tried to remove date, but then there error was:
I get an Exception: Invalid field name: Count!
Any input will greatly help.
The text was updated successfully, but these errors were encountered: