Python commands not working (Tweepy, shabang, git)
I just started using Python in order to extract Twitter data, using Tweepy. I've had trouble installing pip, but got around it. Had trouble with git, but downloaded git and got around it. But when i try the import function in python to import tweepy, it gives an error message.
So people say you need the shabang thing, but it won't recognize the #!... I just don't know what to do anymore.
See also questions close to this topic
Selenium Python Unable to scroll down, while fetching google reviews
I am trying to fetch google reviews with the help of selenium in python. I have imported webdriver from selenium python module. Then I have initialized self.driver as follows:-
self.driver = webdriver.Chrome(executable_path="./chromedriver.exe",chrome_options=webdriver.ChromeOptions())
After this I am using the following code to type the company name on google homepage whose reviews I need, for now I am trying to fetch reviews for "STANLEY BRIDGE CYCLES AND SPORTS LIMITED ":-
company_name = self.driver.find_element_by_name("q") company_name.send_keys("STANLEY BRIDGE CYCLES AND SPORTS LIMITED ") time.sleep(2)
After this to click on the google search button, using the following code:-
Then finally I am on the page where I can see results. Now I want to click on the View on google reviews button. For that using the following code:-
self.driver.find_elements_by_link_text("View all Google reviews").click() time.sleep(2)
Now I am able to get reviews, but only 10. I need at least 20 reviews for a company. For that I am trying to scroll the page down using the following code:
self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(5)
Even while using the above code to scroll the down the page, I am still getting only 10 reviews. I am not getting any error though.
Need help on how to scroll down the page to get atleast 20 reviews. As of now I am able to get only 10 reviews. Based on my online search for this issue, people have mostly used: "driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")" to scroll the page down whenever required. But for me this is not working. I checked the the height of the page before and after ("driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")") is the same.
Create a new column from itereated rows of timedate data
I am attempting to create a downward velocity model for offshore drilling which uses the variables Depth (which increases every 1 foot) and DateTime data which is more intermittent and is only updated every foot of depth:
Dept DateTime 1141 5/24/2017 04:31 1142 5/24/2017 04:32 1143 5/24/2017 04:40 1144 5/24/2017 04:42 1145 5/25/2017 04:58
I am trying to get something like this:
Where Velocity iterated down dept/(DateTime gap)
one to one mapping in shell script
I am in process of migration. Migrating from old set of servers to new set of servers, where there is no logical relationship in the server names between the 2 sets. I have a script that runs on old server, takes all necessary backups and the run another script to copy the backups to new server and execute it.
I can combine both scripts(taking backup and copying to new server), if I can include a logic to map the old server to new server. Is there a way I can do this.
Old server New server King Queen Bat Ball water fire sand rock
What I am expecting is, if the script is run on server 'King', I want the script to identify that the corresponding new server is 'Queen' and copy the backups to Queen.
How to fix "Unable to unlink old *: No such file or directory"?
I have cloned a branch from a remote repository:
git clone -b feature/feature1 http://..... git status On branch feature/feature1 Your branch is up to date with 'origin/feature/feature1' nothing to commit, working tree is clean
Now I am trying to use
git rebase -ito squash the two last commits:
git rebase -i HEAD~3 pick ... pick .... squash ...
However, I'm getting this error:
error: unable to unlink old 'file1': No such file or directory error: unable to unlink old 'file2': No such file or directory error: unable to unlink old 'file3': No such file or directory hint: Could not execute the todo command hint: hint: squash 3b6cabf2541e333d614c3cd5dbbb82a37037cc14 some commit hint: hint: It has been rescheduled; To edit the command before continuing, please hint: edit the todo list first: hint: hint: git rebase --edit-todo hint: git rebase --continue Could not apply 3b6cabf... some commit
Why do I get this error and how can I fix it?
Commit a single file in Visual Studio Professional 2017
I'm working with an application that is stored on Github. I'd like to commit a single file. It seems like this would be trivial but I don't see how it's done.
If I right click on the file I want to commit and select the Commit command, it seems to show that all modified files will be checked in. There is a Commit All button/dropdown that becomes enabled when I start entering a commit message. But the dropdown has no option to commit less than everything.
Surely this is supported.
How to sync code between AWS CodeCommit and GitLab?
The upstream is AWS Codecommit. So whenever code is pushed I want to pull it and then push it to a GitLab repository. Currently I'm doing this using a
cronjobon a local machine which needs to be available all the time. Can this be accomplished in any other way?
Tweepy stream.filter documentation
stream.filter(follow, track, async, locations, stall_warnings, languages, encoding, filter_level)
How do I use these streaming options: - follow - track - async - locations - stall_warnings - languages - encoding - filter_level
I've searched everywhere but I haven't found anything. I know there's a closed thread over here about the same thing, but it didn't help at all.
Tweepy and Python: how to list all followers with their following date?
how to list all followers with their following date of particular Twitter account through Tweepy ?
Stacked in a loop creating friendship with tweepy
So Im trying to follow users, but the problem is that it works on every user except the last one that I have in my to_follow.txt:
Chile_Temblores Aguas_Antof costaneranorte_ onemichile Edelaysen Chilquinta600 CGE_Clientes Frontel_ EnelClientesCL javi1597
The code that Im using is the following:
def createFriends(api): accounts = open("to_follow.txt", "r") friends = api.friends_ids() print("friends:", friends) follow = accounts().split('\n') print (follow) for account in follow: if account not in follow: api.destroy_friendship(account) for account in follow: if account not in friends: print("account: ", account) fuentes.append(account) api.create_friendship(account) print("friendship created") print(fuentes) accounts.close()
So when I print what is happening, it stops in javi1597 and it does not exit de execution, Where is the problem?
ZSH on Linux doesn't recognize valid options in a shell script
zshdoesn't recognize options set with
-o, but only when its in a shebang, and on
The following script fails on
zsh 5.6, and the latest git:
#!/bin/zsh -o pipefail thiswillfail | echo 'hello, world' echo $? exit
hello, world /home/prajjwal/script:2: command not found: thiswillfail 127
/bin/zsh: no such option: pipefail
- The script on
MacOS Mojave. This appears to be failing on every
Linuxversion I've tried so far, though.
- Manually invoking
/bin/zsh -o pipefailon a terminal
- Setting the option with
set -o pipefailafter the shebang in the script.
What I've tried
- Emptying my
.zshrc's to ensure one of my settings isn't causing this.
While I'm only trying to get
pipefailto work, this refuses to work with any other options that I try to set, even though all of them are mentioned in
- The script on
Bash scripting shebang
I have this simple script:
#!/bin/dash echo "Shell used:" $SHELL
I expected to get:
Shell used: /bin/dash
But instead of the output is:
Shell used: /bin/bash
I'm running the script as:
can't run r script from pycharm
I am using pycharm with MAC, I am trying to execute R script even-though I have R compatibility:
#!/usr/bin/env Rscript lambda = 1.5 T=4 nsamp = 8
And I get the error:
lambda = 1.5 ^ SyntaxError: invalid syntax
How to fix it?