tweepy first program: doesn't recognize API call - twitter

I am trying to write my first "helloworld" program to post on Twitter.
The program works fine with print("helloworld").
It also works with import tweepy.
But as soon as I try to assign my IDs, I get errors that it doesn't recognize the API calls. (see attached screenshot)
Maybe its obvious, but I am a beginner Python programmer, and I'm basically copying what I saw in a YouTube video.
code+terminal screenshot

You should be able to fix this issue by replacing the import with
from tweepy.auth import OAuthHandler
and then replace your auth= line with
auth = OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
Now as to why this is occuring - it could be dependant on what's being imported. If you have another tweepy.py file for example, it could be getting picked up as the file to import from, which of course, is likely wrong. Using the from import resolves this. You can find out which file was being used by adding (still using the code from the version in the image you posted)
print(tweepy.__file__)
This'll give you an idea whether the correct file was being imported or not.
Hope that helps.

I accidentally typed “python helloworld.py” instead of “python3”and it magically worked! So now I just run it that way.

Related

Save google sheet file in specific directory in google drive using Colab

In Colab, I haven't could to know how I can export a google sheet file in specific directory in google drive.
I know how I can export .csv and .xlsx to specific directory and
I know how I can export .gsheet to my general drive space
Could you help me with this please?
Thanks you a lot
The method that I provide here assumes that you have no problem in creating a new spreadsheet file in your notebook. You can create the new spreadsheet using the code below:
%pip install --upgrade gspread #IMPORTANT
import gspread
print(gspread.__version__) # make sure gspread is of the latest version
from google.colab import auth
from google.auth import default
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
sh = gc.create('newSpreadsheetFileName', folder_id='yourFolderID')
wb = gc.open('newSpreadsheetFileName').sheet1
After that you should be able to play around inside the first sheet of the workbook wb. By play around, I mean you can import the contents of a data frame, list, etc. If you are unfamiliar with handling Gspread items, you can follow the official documentation. You don't need to move it anymore as it is already created in the folder that you want it to be in.
Advanced notes:
Note that I put an "IMPORTANT" comment beside the pip upgrade line. I include it here because as of writing, the default version of gspread is 3.4.2, which has a bug where you would not be able to input the folder_id parameter into the create()
or copy() function (for further dive in click here). This bug seems to have been fixed in the latest version of gspread, so the update is required. FYI, I am currently using version 5.4.0 and everything that I showed you in the code snippet should work fine. It's actually a little odd that Google don't just let us use the latest version of their library out of the box, honestly.
Hopefully this can help!
Cheers

Cytoscape won't let me upload table to a network collection the only option was to unassigned table. Does anyone know how to resolve this?

the drop-down option isn't available so my table is automatically imported as unassigned table. Anybody come across this issue before? Or is there something wrong with my table setting?
cytoscape screenshot
Not sure what you were expecting. According to the screenshot, you don't have any networks open, so an imported table can only be unassigned. If, on the other hand, you are trying to import a network, you need to use import network from file, not import table from file.
-- scooter
I had the same issue, and ended up spending 3-4 hours on this.
This icon on the tool-bar allows loading of networks from tables without any issue. I was very lucky to find this solution in a video on YouTube(!): https://youtu.be/Z8jUmJL2HFw?t=52, but not in the Cytoscapes documentation.
To me, Cytoscape's file import system felt very un-intuitive. I am not sure why cytoscape does not have a unified import system for loading simple (csv/tsv) tables. Following are few ways that did not work in my case. I am using version 3.9.0. In both of these cases the table got imported as 'Unassigned table'.
Drag and drop 'Edge Table'/'Network table'.
File > Import > Import from file
I went through the documentation and I am still not sure what is the use of 'Unassigned table'. How to assign the columns as source, target etc in the 'Unassigned table'? Even the sample tables shown in the Cytoscape's manual did the same(!).
By the way, I am not sure why the Cytoscape's documentation is not intuitive. For example, I googled 'cytoscape import table' and this slide show showed up as a 1st result: https://cytoscape.org/cytoscape-tutorials/protocols/importing-data-from-tables/#/5 . From the title of the slideshow i.e. 'Importing data from tables', I assumed that it will guide me through how to generate network from tabular data. However, instead it shows how to load data for nodes, which does not create a network(!). Why not demonstrate how to load edge/network data and guide us through the process till the generation of the network? I hope this will improve in next versions of CytoScape.
Anyways, I hope the solution helps.

Can't access objective-c method from swift. Bridge setup, and obj-c class instantiates

This is my first IOS application and all has gone well up to this point. My code is in Swift and I need to use the Gold Raccoon FTP library, which is in Obj-C, in my application: https://github.com/albertodebortoli/GoldRaccoon
I imported the Gold Raccoon files and created the bridge header. The main class you work with is the GRRequestsManager, which I can successfully instantiate in a running app. I cannot however access the addRequestForUploadFileAtLocalPath method in that class.
I initially just had the GRRequestsManager.h import statement in the bridge file. Since that inherits GRRequestsManagerProtocol.h that has the actual method I'm trying to use defined in it (addRequestForUploadFileAtLocalPath), I decided to add that to my bridge header file and lo and behold all of a sudden auto suggest popped up for the method and I could put it in my code with no errors. A few minutes later I got an error message again and it won't work now no matter what. I've tried closing and reopening Xcode and cleaning/rebuilding to no avail.
Below is a combined image (can only post 1 image due to my points) showing first the bridging-header and second (separated by the red line) the error in the code where I'm trying to call the method. You can see it recognized the class just fine.
Well I went ahead and added an include to every single header file in the Gold Raccoon library to my bridging header and now the method is recognized and my code compiles! I'm still not too sure why I needed to do that but it did the trick. If anyone cares to explain the why I would love to understand it.

Parse iOS SDK Localizing

I am using Parse SDK as a backend and when application loading data from server i see label "Loading". But my app using another language and i wanna translate it. How can i fix it?
Image here
I am tried to change simulator language and and changing value of Localization native development region key in plist.
Anyone had this problem? I think there is very simple answer, but i cannot find it. :)
Thank you for help!
So after a long search, i discovered that you should create a file named "ParseUI.strings" in order to change UI elements like "Loading.." as you mentioned. You can see the file in the image below. You should use at least ParseUI framework 1.1.6 for this method.
After you create a file and named it as "ParseUI.strings" you can change UI elements which parse provides us. You can see which strings are editable here.
In your example you want to change "Loading..." string, so all you have to do is enter the code in your ParseUI.strings file.
"Loading..." = "Whatever thing you want to say...";
Thats it, it worked for me.

Snap and Run Objective Flickr example - Won't compile?

Okay, so this seems pretty embarrassing but I downloaded objectiveflickr and opened up the Snap and Run example, entered my API and Secret Key in the SampleAPIKey.h file and get the error:
error Supply your own Flickr API key and shared secret
Here is a screenshot of the error (Please be aware that's not a real API key or secret, I made it up for illustrative purpose!)
Error screenshot
I'm not new to iPhone/iPad development but I am completely new to adding this type of option to an app so thought if I could have a look at the example it would help me to figure out the implementation in my own app....the problem is I can't even get the example working which is slightly worrying!!
Once you have filled in your own info for key & secret in the .h file you just comment out the line above that says error
Simple as that.
Also note that the auth URL has to go into the info.plist file, not just in the .h so check out the sample and copy from that.

Resources