I was trying to execute a python file which is not saved in the python directory but in a different one in linux (fedora) terminal. What I tried was:
$ exec(vsh1.py)
which resulted an error:
bash: syntax error near unexpected token 'vsh1.py'
Could anybody find a solution please...
Thanks in advance
Locate your python's source file
find / -name vsh1.py
and once located run
python /path_you_found/vsh1.py
if you want your script to be seen from any location for the interpreter you have to add it to PYTHONPATH:
PYTHONPATH=$PYTHONPATH:/path_you_found/vsh1.py
if your script in the same directory you can just run
python ./vsh1.py
exec(python2.7 filename.py) This will be the command.
You want this:
python vsh1.py
Or if you have your script set up properly with executable permissions and a "shebang line":
./vsh1.py
Related
I have a python script where I need to create an executable via pyinstaller. Successfully created the exe, but shows the above error while running.
I have already searched on the web and tried many solutions but none of them is working. tried with # -*- coding:utf-8 -*- in the first line of the script but fails.
using Python3.7, PyInstaller3.5
Can anyone help me with this?
Ensure you are not calling the executable using python again.
As in
python long-path-to-the-converted-scrip\script.exe
It is a common mistake, due to the fact that you used python to run the script before, then you try to recycle the same command but forget to delete the python call. The long path to the script (now converted to exe) obfuscates the fact that python is no longer needed at the beginning...hence your error.
Resolution: Please execute the exe without python command.
Example: If you have converted test.py, please go to the directory Current Directory/dist/test/ and either double-click on test.exe or run test.exe from command line.
I'm trying to open a .py file on git bash but it doesn't work.
I have tried to follow some instructions like running python <filename> but it doesn't work for me.
When I run
python python_basics
I expect it will open the .py file but it says it can't open file 'python_basics':
[Errno 2] No such file or directory
From this question, the problem may very well be caused by Git Bash itself.
I would recommend you try running your Python file from a different terminal (Command Prompt or PowerShell if you are using Windows), using the command suggested in the comments:
python python_basics.py
Thank you for your question, I am here to help you and who will see this question.
if you mean you want to open the file like when click on the file and open it
you can use this command
Start filename.py
but if you want to open the file inside the gitbash use this command
vim filename.py
and if you mean to run the file from gitbash you can use this command
python pythonFileName.py
Now if the above command did not work with you, and you are in the windows10 Pro platform you should go to
environment variable >> Then system variable >> then choose path >> then Edit >> and put the python path >> restart the terminal and run it again
Notice: All of the above I tried and used in windows10 pro.
Thanks,
Hope to help anyone,
First check the python version installed on your system.
by command-
python --version.
If not found
set
$ PATH=$PATH:/c/Python27/
Adapting the path will solve your problem.
Thank you in advance for answering my question.
I tried to execute my python files on Windows command prompt. However, '************' is the only output I can get regardless of the files I execute.
For example, test. py consists of only one-line code which is
'print("Python check")'
troubleshooting_1.py is just the same code as test.py. It consists of
'print("troubleshooting")
I don't know why this problem occurs.
Below is the result of where python
> C:\Users\User\Desktop\sshackathon_project_2>where python
C:\Users\User\Desktop\sshackathon_project_2\python
C:\Users\User\Desktop\sshackathon_project_2\python.py
C:\Program Files\Python37\python.exe
Windows command prompt
I am trying to run following simple script file:
#! /usr/local/bin/red-063
Red []
print "testing"
quit
But I am getting following error:
** Script Error: Invalid compressed data - problem: -3
** Near: script: decapsulate
if none? script
This error is mentioned on this page: https://github.com/red/red/blob/master/environment/system.red but details are not clear and also how it can be corrected.
Similar script for Rebol 2.7.8 works. Where is the problem?
The problem is with rebol not being able to unpack. See here.
Essentially create a batch file or shell script in the directory as the red binary to invoke the red binary.
I'm attempting to load several modules for building a library on Linux but am told that the command 'module' doesn't exist. I've Googled around and discovered that the solution was to source a directory called "module" which I am unable to locate despite extensive searching.
I'm not quite sure what I should and any help would be appreciated (it might help to know that the makefile I'm working with uses csh while my default shell is bash). Thanks!
I tried to reproduce it and it turns out that for me sourcing
source /etc/profile.d/modules.sh
in th .sh script helps for bash and similar. For csh and tcsh, you have to add
source /etc/profile.d/modules.csh
to the script. Note, that this line must come first and then the
module load foo
line.
I got here as I was searching for ways to install multiple php versions in CentOS7 and https://blog.remirepo.net/post/2019/05/22/PHP-7.4-as-Software-Collection was one of the articles I tried to follow and encountered the same "module: command not found" issue.
Sourcing /etc/profile via command:
. /etc/profile
seems to make the "module load" work.
Credits to fadishei in https://forums.fedoraforum.org/showthread.php?262708-module-command-not-found
To make the version of php (e.g. php7.4) persist, append the following to file /etc/profile.d/custom.sh
source /etc/profile.d/modules.sh
module load php74
Reboot and run the php --version to cross-check that php 7.4 is the current version installed.
I think that you have to put this in your script to define the module command:
module () {
eval `/usr/bin/modulecmd bash $*`
}
This was working for me
#!/bin/bash -i // it will make this interactive