access sastrawi folder from command prompt - python

I am trying to access sastrawi folder
The following steps are done
I downloaded the Composer-Setup.exe file from composer page and got successfully installed.
I installed Composer-Setup in sastrawi folder
I get sastrawi folder from https://github.com/sastrawi/sastrawi
I executed the command for accees folder sastrawi in command prompt
php composer.phar require sastrawi/sastrawi:^1
This line generates the error message: could not open file composer.phar
how to resolve this error???

Related

Unable to execute word document containing python code via cmd

I created a simple hello world text document named "hello.py" stored in a directory in a drive. I then opened cmd, navigated to the directory where the document was stored, and typed in
py hello.py
And then cmd gives me this error:
C:\Users\nufil\AppData\Local\Programs\Python\Python39\python.exe: can't open file 'D:\Python\hello.py': [Errno 2] No such file or directory
How do I rectify this error and make cmd run my code?

Issue running terminal commands through jupyter notebook

I am currently running a jupyter notebook from a github repo. One chunk goes like this:
for file in os.listdir('data/'):
path = 'data/' + file
os.system(f"python OpticalFlowGen.py --type {target} --file {path}")
The variables target and path were defined and no errors were raised.
When the OpticalFlowGen.py file is run on the terminal with python OpticalFlowGen.py ---type 'Train' -- file 'data/video.mp4', a popup appears and closes after the video file is processed by openCV and .jpg files will be saved in the system. However, when this command is run on the jupyter notebook, nothing pops up and no files are saved. You can access this .py file from the same repository here.
Currently I have to run manually on the terminal file by file so save all the image output before I can run the notebook without error. However, it will become an issue when I have too many video files, not using the for loop will be too cumbersome. Any idea on how to solve this issue?
In a Jupyter Notebook you don't have to use os.system, instead try to use !:
for file in os.listdir('data/'):
path = 'data/' + file
# Use
# ! - for terminal commands
# {} - for a variable in the terminal command
!python OpticalFlowGen.py --type {target} --file {path}

cd directory_name python python_file.py gives error in command line " the system cannot find the path specified"

I am running python file from command line. To be more specific my .py file is in location F:\new_github_code\cocktail_party\data\audio\audio_downloader.py>. I want to run audio_downloader.py file from the cocktail_party directory not from the audio directory.
I tried by using the following script from cmd. Any help will be appreciate
enter image description here
Try this. It will work:
python data\audio\audio_downloader.py

Python can't run absolute script?

I encountered such a weird situation:
naivechou#naivechou/~>python test.py
test
naivechou#naivechou/~>pwd
/home/naivechou
naivechou#naivechou/~>python /home/naivechou/test.py
C:\toolchain\python\python.exe: can't open file '/home/naivechou/test.py': [Errno 2] No such file or directory
My working directory is /home/naivechou/, test.py is in there.
If I run test.py with absolute path, I'll get an error message of No such file or directory.But everything will be fine if I enter that directory and then run it. What's wrong with python?
Try moving into the folder where the python script is located and do a "ls" command there in Linux. if windows then do 'dir'. if you see the required file there then execute the following command
C:\location_where_the_script_is> python yourfile.py
For commands entered on the command line, Windows doesn't recognize forward-slashes as directory separators.
Your second example is looking in the current directory for the literal filename /home/naivechou/test.py, and of course such a filename does not exist.
Use backslashes instead, as is the Windows way:
python \home\naivechou\test.py

failed to run python scripts with jenkins

I am trying to run a Python job. I have created the following folder:
C:\Users\herod\jenkins_ws\workspace\window_testing
and added the script "testing.py" to it.
The script is very simple:
if __name__ == "__main__":
print "hellow world !"
f = open('test_log.txt','w')
f.write("hello\n")
f.close
But I am getting the following error when running it from Jenkins (if I run it from command line it works):
>Building remotely on windows1 (widndows_genereal) in workspace C:\Users\herod\jenkins_ws\workspace\window_testing
[window_testing] $ python C:\windows\TEMP\hudson5234791200924972506.py
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "python" (in directory "C:\Users\herod\jenkins_ws\workspace\window_testing"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:775)
at hudson.Launcher$ProcStarter.start(Launcher.java:355)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1024)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:991)
What am I doing wrong ?
Here is what I have tried:
in the configure for the job at the build section I choose "execute python script" and than entered the testing.py file - not working.
I also tried to enter there python testing.py and python.exe testing.py - not working.
Trying to write a python script in the "script" edit text - not working.
If I change the execute type from python to batch file and than it shows that it pass but actually it didn't run the python script.
update2: (after trying Technext solution) I got the next error:
Building remotely on windows1 (widndows_genereal) in workspace C:\Users\herod\jenkins_ws\workspace\window_testing
[window_testing] $ python C:\Users\herod\AppData\Local\Temp\hudson4767788636447260218.py
Traceback (most recent call last):
File "C:\Users\herod\AppData\Local\Temp\hudson4767788636447260218.py", line 1, in <module>
testing.py
NameError: name 'testing' is not defined
Build step 'Execute Python script' marked build as failure
Finished: FAILURE
Whenever running python as a command in batch file, Give the full path of Python executable or you will have to configure the path in the Jenkins environment. Say your python executable is kept in C:\Python27 folder, then execute the following:
C:\Python27\python.exe <full path of python file to execute>
Since the python script runs fine on the command line but has issues when running through Jenkins, it most probably means that the user with which Jenkins is running has issues finding Python executable i.e., python.exe. If it is possible (and feasible) for you to change the Jenkins user, then please change it using the process i described here. Make it run as the same user with which you are running the program successfully on command prompt.
When you install Python in Windows, there is an option to "Add Python to System Path" which you should make sure is selected. You can safely install over your existing Python if you're not sure. This worked for us in Jenkins using the Python plugin.

Categories

Resources