Python programs won't run on commandline but will in shell?
So everything was working fine, python was working fine. No problems until I decided to make a program (in python) which could be useful for stuff that I do often (quickly check the price of Bitcoin). So I wrote it, it worked perfectly both in Console and in the Shell. Then I make a shortcut to the desktop that I wanted to be able to quickly access it by pressing F9. After I create the shortcut, all of a sudden my python programs won't run from the Console! I press F9 and it shows the single frame where it runs then disappears. I played a bit and removed the
imports and then it ran (but crashed after it didn't get anything), it seems that now, any library that I haven't installed from the internet (
Math, every Library that comes with python) will import normally and python works. But if I try to use libraries that I installed (which used to be working perfectly fine) from the internet such as
Pyperclip, the program just doesn't run. I even tried reinstalling them with
pip install. Has anyone else ever encountered this problem? Can someone help me to be able to run them again?
See also questions close to this topic
Concentric circles code will give me one more circle than I input
My concentric circle code works, but when I input the number of circles I need, it will give me one more circle than I want. For example, if I input 7 circles, it will give me 8, but it only does that more over 6 circles. I was wondering what was wrong with my code and why it does that. Thanks.
my code is
if r>=50 or r<=200: #if radius is in range, draw circles for c in range (r, 1, int(-r/num_circles)): turtle.fillcolor(random.random(),random.random(),\ random.random()) #circles will be a random color turtle.begin_fill() turtle.circle(c) turtle.penup() turtle.left(90) #concentric turtle.forward(r/num_circles) turtle.right(90) turtle.pendown() turtle.end_fill() turtle.hideturtle() time.sleep(5) turtle.clear() #clears screen
How to create function that returns n and m
This is from the Tower of Hanoi problem. Following up from: How to print nth line of a function output
A = [1,2,3] B =  C =  m =  def move(n, source, target, auxiliary, output_lines=None): if output_lines is None: output_lines =  if n > 0: move(n - 1, source, auxiliary, target, output_lines) target.append(source.pop()) output_lines.append('%d %d %d' % (len(A), len(B), len(C))) move(n - 1, auxiliary, target, source, output_lines) return output_lines a = move(len(A), A, C, B)
How can I create a function
hanoi(n,m)where n returns the number of disks and m returns the no. of moves? A should reflect something like
A = [list(range(1,n))]. I'm not sure how to incorporate the code above into the function
hanoi(n,m). Sorry noob here and still learning.
remove columns and replace title in different column when merging csv files
Basically I want to remove the region column in each case and replace it to the name of the column, my desired result looks like this:
My current code for merging the csv files and moving the settlement date to the left is this:
import pandas as pd data1 = pd.read_csv("QLD.csv") data2 = pd.read_csv("VIC.csv") result = pd.merge(data1[['REGION', 'TOTALDEMAND', 'RRP','SETTLEMENTDATE']], data2[['REGION', 'TOTALDEMAND', 'RRP','SETTLEMENTDATE']], on='SETTLEMENTDATE') cols = result.columns.tolist() cols.insert(0, cols.pop(cols.index('SETTLEMENTDATE'))) result = result.reindex(columns= cols) result.to_csv("masterfile.csv", index=False)
My question is how could I modify my code to achieve my desired result?
stable installed - (error reading rustc version)
I have trouble running rust in my linux box.
Here is my installation log:
>> curl https://sh.rustup.rs -sSf | sh info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /home/linuxbox/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile files located at: /home/linuxbox/.profile /home/linuxbox/.bash_profile You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation >1 info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2019-01-17, rust version 1.32.0 (9fda7c223 2019-01-16) info: downloading component 'rustc' 79.5 MiB / 79.5 MiB (100 %) 883.2 KiB/s ETA: 0 s info: downloading component 'rust-std' 54.3 MiB / 54.3 MiB (100 %) 611.2 KiB/s ETA: 0 s info: downloading component 'cargo' 4.4 MiB / 4.4 MiB (100 %) 761.4 KiB/s ETA: 0 s info: downloading component 'rust-docs' 8.5 MiB / 8.5 MiB (100 %) 553.6 KiB/s ETA: 0 s info: installing component 'rustc' info: installing component 'rust-std' info: installing component 'cargo' info: installing component 'rust-docs' info: default toolchain set to 'stable' stable installed - (error reading rustc version) Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically.
To configure your current shell run source $HOME/.cargo/env
I have set the the environment variable and my path shows the
.cargo/bin/cargo. However, when I type 'cargo` I am getting
>> cargo bash: /home/linuxbox/.cargo/bin/cargo: Permission denied
.rustupdirectory permissions are:
>> ll .cargo/ .rustup/ .cargo/: total 16K 4.0K drwxr-xr-x 3 linuxbox linuxbox 4.0K Jan 20 10:13 ./ 4.0K drwxr-xr-x 27 linuxbox linuxbox 4.0K Jan 20 10:08 ../ 4.0K drwxr-xr-x 2 linuxbox linuxbox 4.0K Jan 20 10:08 bin/ 4.0K -rw-r--r-- 1 linuxbox linuxbox 37 Jan 20 10:13 env .rustup/: total 28K 4.0K drwxr-xr-x 6 linuxbox linuxbox 4.0K Jan 20 10:12 ./ 4.0K drwxr-xr-x 27 linuxbox linuxbox 4.0K Jan 20 10:08 ../ 4.0K drwxr-xr-x 2 linuxbox linuxbox 4.0K Jan 20 10:13 downloads/ 4.0K -rw-r--r-- 1 linuxbox linuxbox 124 Jan 20 10:13 settings.toml 4.0K drwxr-xr-x 2 linuxbox linuxbox 4.0K Jan 20 10:13 tmp/ 4.0K drwxr-xr-x 3 linuxbox linuxbox 4.0K Jan 20 10:12 toolchains/ 4.0K drwxr-xr-x 2 linuxbox linuxbox 4.0K Jan 20 10:13 update-hashes/
Permissions seem o.k but clueless why am I getting
Could someone shed some light to help troubleshoot/fix this?
Can't set ffmpeg header when using file for input
I'm attempting to set headers (as suggested here) for my ffmpeg
concatcommand like so:
ffmpeg \ -f concat \ -safe 0 \ -protocol_whitelist file,http,https,tcp,tls \ -headers $'Content-Type: audio/wav\r\n' \ -i 'inputs.txt' \ -c 'copy' 'output.wav' \ -v trace
where my input file is structured as such:
file 'https://path/to/file1' file 'https://path/to/file2' file 'https://path/to/file3'
However, when I run the command, ffmpeg doesn't set the headers, as seen by the output of -v:
[http @ 0x7fa133d01080] request: GET / HTTP/1.1 User-Agent: Lavf/58.20.100 Accept: */* Range: bytes=0- Connection: close Host: localhost:3001 Icy-MetaData: 1
What's strange is if I set my input not through an input txt and just through
-i /path/to file(as seen below) it works just fine.
ffmpeg \ -f concat \ -safe 0 \ -protocol_whitelist file,http,https,tcp,tls \ -headers $'Content-Type: audio/wav\r\n' \ -i 'https://google.com' \ -c 'copy' 'output.wav' \ -v trace
Output of -v:
[https @ 0x7fed3ac03940] request: GET / HTTP/1.1 User-Agent: Lavf/58.20.100 Accept: */* Range: bytes=0- Connection: close Host: google.com Icy-MetaData: 1 Content-Type: audio/wav
Not sure why reading the inputs through a file would affect the headers getting sent. For now the workaround is to use a string concatenating all of the inputs (a bit messier than I'd like), but I'm curious if anyone might know why this is happening.
UPDATE: According to this post I have to read inputs through a text file, so I'm back to square one....
how to match a specific file extension in shellscript
I looked some other posts and learnt to match file extension in the following way but why my code is not working? Thanks.
1 #!/bin/sh 2 3 for i in `ls` 4 do 5 if [[ "$i" == *.txt ]] 6 then 7 echo "$i is .txt file" 8 else 9 echo "$i is NOT .txt file" 10 fi 11 done