First time to install python, and test in git bash - python

OS : Windows 10
It is the first time to install python.
I want to run python on git bash.
I haven't used python or git bash before.
I installed portable git.
C:\Users\ username \Desktop\PortableGit
I created a small file named ib in Portable git folder, whose content is
I installed python
C:\Users\ username \AppData\Local\Programs\Python\Python310
Run git-bash.exe in portable git folder,
and check the version of python, and run ib.
python --version
./ib
It says no such file or directory. The code ./ib didn't work. Can you teach me?
If you need more information, you can ask me!(tasks/screenshots)

You need to add the directory which contains the python executable to the PATH variable. One way to do this is to edit .bashrc in your home directory and add a line similar to
export PATH=$PATH:/path/to/python
replacing /path/to/python with the directory where python3 is located.

Related

Library is not installed on PATH - How can I install on path?

I am running this notebook in my managed notebooks environment on Google Cloud and I'm getting the following error when trying to install the packages: "WARNING: The script google-oauthlib-tool is installed in '/home/jupyter/.local/bin' which is not on PATH.
Consider adding this directory to PATH."
Here is the python code that I'm trying to run for reference. https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_monitoring/model_monitoring.ipynb
Any suggestions on how I can update the package installation so it is on path and resolve the error? I'm currently working on GCP user-managed notebooks on a Mac.
Thanks so much for any tips!
RE
Open up your shell config file (likely .zshrc because the default shell on Mac is now zsh and that's the name of the zsh config file) located at your home directory in a text editor (TextEdit, etc) and add the path to the executable.
Like this:
Open the file:
open -e ~/.zshrc
Edit the file:
Add this line at the top (may vary, check the documentation):
export PATH="/home/jupyter/.local/bin"
That may not work, try this:
export PATH="$PATH:/home/jupyter/.local/bin"
Your best bet is to read the package documentation.
After saving the config file, run source ~/.zshrc and replace .zshrc with the config file name if it's different OR open a new terminal tab.
What this does is tells the shell that the command exists and where to find it.

Command 'blender' not found, despite executing from the installed directory

I am trying to execute a python file using the python from blender. I have downloaded and placed the blender inside my user's home directory. But everytime I try to execute blender command I get the following error:
Command blender not found, but can be installed with:
sudo snap install blender # version 2.79b, or
sudo apt install blender
See 'snap info blender' for additional versions.`
My current directory is:
$ pwd
/home/rishik/Applications/blender-2.79b-linux-glibc219-x86_64
I executed the following:
blender --background python somepythonfile.py
I do not understand how to invoke python from blender now.
Linux (by default) doesn't put the current working directory in the search PATH. If your blender directory is not in PATH, then you need to specify a full path, even for the current directory:
./blender --background python somepythonfile.py
You can add . to the search path, but this is considered a bad idea due to the possibility of malware impersonating a common command (like ls).

How do I run my Python script? Why does the command line tell me "no such file or directory"?

I have Python 2.7 installed at C:\Python27 and I have added the path C:\Python27\; to the environment variables and .py: to PATHEXT. I am able to launch Python.
I downloaded a folder google-python-exercises to my desktop, which contains a script hello.py.
Following the advice in the Google Developers course, I try to run the script by using python hello.py at the command prompt.
When I attempt this, I get the message: python: can't open file 'hello.py: [Errno 2] No such file or directory. What is wrong, and how am I supposed to fix it? I found that I can solve the problem by running cmd from the folder, but this seems like a temporary solution.
Python cannot access the files in the subdirectory unless a path to it provided. You can access files in any directory by providing the path. python C:\Python27\Projects\hello.py
I resolved this problem by navigating to C:\Python27\Scripts folder and then run file.py file instead of C:\Python27 folder
Options include:
Run the command from the folder where hello.py is located (this way, hello.py is already a relative path to the file). This is the solution that OP found.
Give a proper path to the hello.py file - either absolute (e.g. C:/Users/me/Desktop/google-python-exercises/hello.py) or relative (for example, google-python-exercises/hello.py, if the current working directory is the desktop).
Add a path to the folder (C:/Users/me/Desktop/google-python-exercises) to the PYTHONPATH environment variable, and run the code as a module (python -m hello).
In all cases, a path is being given directly - Python will not "search" for the file.
From your question, you are running python2.7 and Cygwin.
Python should be installed for windows, which from your question it seems it is. If "which python" prints out /usr/bin/python , then from the bash prompt you are running the cygwin version.
Set the Python Environmental variables appropriately
, for instance in my case:
PY_HOME=C:\opt\Python27
PYTHONPATH=C:\opt\Python27;c:\opt\Python27\Lib
In that case run cygwin setup and uninstall everything python.
After that run "which pydoc", if it shows
/usr/bin/pydoc
Replace /usr/bin/pydoc
with
#! /bin/bash
/cygdrive/c/WINDOWS/system32/cmd /c %PYTHONHOME%\Scripts\\pydoc.bat
Then add this to $PY_HOME/Scripts/pydoc.bat
rem wrapper for pydoc on Win32
#python c:\opt\Python27\Lib\pydoc.py %*
Now when you type in the cygwin bash prompt you should see:
$ pydoc
pydoc - the Python documentation tool
pydoc.py <name> ...
Show text documentation on something. <name>
may be the name of a Python keyword, topic,
function, module, or package, or a dotted
reference to a class or function within a
module or module in a package.
...
Try uninstalling Python and then install it again, but this time make sure that the option Add Python to Path is marked as checked during the installation process.

Problems running rethinkdb-dump from cron

I'm trying to setup regular backups of rethinkdb, but keep running into issues. How do you setup rethinkdb-dump to run from cron?
Here is my script:
$ cat backup.sh
#!/bin/bash
NOW=$(date +"%Y-%m-%d-%H-%M")
/usr/bin/rethinkdb dump -e my_db -f /root/db_backup/$NOW.tar.gz
The script runs just fine when I run it manually. However, when try and run it from cron it doesn't work and I get the following at stderr:
Error when launching 'rethinkdb-dump': No such file or directory
The rethinkdb-dump command depends on the RethinkDB Python driver, which must be installed.
If the Python driver is already installed, make sure that the PATH environment variable
includes the location of the backup scripts, and that the current user has permission to
access and run the scripts.
Instructions for installing the RethinkDB Python driver are available here:
http://www.rethinkdb.com/docs/install-drivers/python/
It appears to be a Python environment issue, but I cannot figure out how to make it happy... thoughts? Help!
When you run it from that backup.sh script, it maybe run without correct PATH setup and cannot found the PATH of rethinkdb-dump.
First, let find out where is rethinkdb-dump
which rethinkdb-dump
(on my pc, I guess it's very different on your pc)
/usr/local/bin/rethinkdb-dump
Now, try to append the PATH to your script backup.sh
#!/bin/bash
export PATH="$PATH:/path/to/folder/contain-rethinkdb-dump"
# The rest of your script normally
So take my example, I will put it like this:
export PATH="$PATH:/usr/local/bin"
I think your rethinkdb-dump live outside normal bin folder (/usr/bin, /usr/local/bin etc)
The python installer for windows installs scripts and packages in subfolders here:
$env:APPDATA\Python\Python37 for powershell
%APPDATA%\Python\Python37 for cmd
cd this directory to see /Scripts and /site-packages (pip packages)

/bin/env: python: No such file or directory (Windows through Git Bash trying to install new Parse Cloud Code)

Trying to install python from the link here does not seem to give access to the python command in Msysgit... following the instructions here, does not actually say how to get python to work as needed.
Current error when running parse new project_name is:
/bin/env: python: No such file or directory
I believe it's likely because it installed it at C:\Python... anyone know how to fix this?
This error means that Git Bash does not know where your python.exe is. It searches your normal windows search path, the PATH environment variable. You're probably failing the 4th step on the instructions already "Make sure Python is working in the Git Bash":
$ python --version
sh.exe: python: command not found
To fix that, append C:\Python (or wherever you installed python) to your PATH environment variable in windows (instructions here). You need to restart the bash after this for the change to take effect. This will allow you to run python from the windows command prompt as well.
C:\> python --version
Python 2.7.2
If you don't want to alter your windows PATH variable or make python only available to git bash, you could create a .bashrc file in your %USERPROFILE% directory and set the variable there:
C:\>notepad %USERPROFILE%\.bashrc
and add
export PATH=/c/Python:$PATH
to the file. That script is executed every time you start the git bash and prepends C:\Python to git bash's PATH variable, leaving the system-wide PATH variable untouched.
Now that you know what has to be done, you can use this shortcut on the bash instead (appends the export command to your .bashrc)
$ echo export PATH=/c/Python:\$PATH >> ~/.bashrc
Hmmm. If you're using Python 2.7 like the instructions say to, you could try instead of that doing "C:/Python27/python.exe" insted of "python".
I think you can add the location of the python.exe in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';' (without quotes) and then add the absolute path of the .exe file which you want to run via Git-Bash.
don't know if this could be your issue, but its always worth a check.
check your python path is set correctly?
computer->properties->advanced system settings-> environment variables->system variables->PYTHONPATH, value = C:\PYTHON20;C:\PYTHON20\DLLS;C:\PYTHON20\LIB;C:\PY THON20\LIB\LIB-TK

Categories

Resources