I am working with a remote machine that I am not administrator in it.
This machine has python 2.6.5 installed and also it appears in PATH.
After I asked they installed in the machine also python 2.7.9, but they refuse to add it to PATH.
is there a way I can execute a script from the command line using the newer version?
You can use the full path to where the python executable is located.
Instead of doing:
python C:\path\to\your\py\file
you do:
C:\Python27\python.exe C:\path\to\your\py\file
with the file path placed in quotes if necessary:
C:\Python27\python.exe "C:\path\to\your\py\file"
Related
I tried to install Python to Windows 10, with the PATH installation included. However, when I click to enter in the Python application, it just appears the setup. I need to access the Python terminal.
Here is the setup
Make sure you are not accidentally opening the Python installation executable. Check again that the Python path is installed properly and try running the command "py" or "python" in the Command Prompt to see if it starts. If it doesn't start and Python is installed on your computer, manually add Python's install location to your PATH.
I'm having an issue using Python in my Mac Terminal Shell.
I used Python through Mac Terminal yesterday, but after I worked in Pycharm this morning, there seems to be an issue with my terminal.
Now when I simply write 'python', I receive this message:
zsh: no such file or directory: /usr/local/bin/python3.7
Any help, getting me back to using Python in my terminal would be appreciated!
Apparently the PATH of your S.O. It can't find the file to launch Python in your terminal so you could:
reinstall Python from the command line (zsh) and validate the "python" command again from the terminal
find the file associated with Python with commands like "find" and then modify the path of the PATH to the path where the Python launcher is
Pycharm has a tendency of changing your PATH after installation.
You have basically 3 options:
Option 1: Reinstall Python and use the path for both pycharm and zsh
I recommend this. It's a little bit of work, but you have a messy situation right now and completely kicking python off the system and then setting the PATH in your bash_profile and Pycharm is cleaner than the other options.
Uninstall Python. Make sure not to touch MacOS system Python.
Install Python
Path in Pycharm
Option 2: Find the path, Pycharm uses and set it in your bashprofile
See 1.3.
Option 3: Install Python and run it separately to the python path pycharm uses.
See 1.2
I have uninstalled Python 2.7 and installed Python 3. But, when I type Python on my command prompt I get this :
"Enthought Canopy Python 2.7.9 ........."
How can I run Python 3 from command line or how can I make it default on my computer? I asked Enthought Canopy help and I was told that I can "have Canopy be your default Python only in a "Canopy Command Prompt". Not sure what it means.
edit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.
Windows selects which executable will be run by searching the directories in-order from the PATH environment variable (source):
The shell now searches each directory specified by the PATH
environment variable, in the order listed, for an executable file
matching the command name. If a match is found, the external command
(the executable file) executes. If no match is found, the shell
reports an error and command processing completes.
You can modify PATH to put your Python 3.4 directory (typically C:\Python43) before your Python 2.7 directory. From Windows 7 and up, you can use where python to confirm which python will be run (first line of the output).
After editing each path and creating a new variable for each python version, be sure to rename the python.exe to a unique one. i.e. "python3x" . then you can call it in the command line as "python3x". I am assuming that the original python installed (2X) retains the python.exe of which when you call "python" in the command line, it will show the 2x version
You can copy python.exe to python3.exe.
If you are using Anaconda, then you will find it in the sub directory of your environment, for intance, c:\Anaconda\envs\myenvironment.
I've recently started using sqlmap and found out it needs python2.7. I installed 2.7 and added it to my PATH along with 3.4. My current path looks like this:
c:\Other-Programs\;c:\Python27;c:\Python34
So When I try to run sqlmap i follow these steps:
1. Open up cmd as admin
2. cd c\:sqlmap
3. python sqlmap.py
At this point, sqlmap informs me that Python 3.4 is incompatible.
I tried just doing:
3. python27 sqlmap.py
That returns an error stating that it's not a command.
Basically I want to know how I can specify the version of Python I want to use when running a command for sqlmap.
try using full path of python exe C:\Python27\python.exe sqlmap.py.
While you normally would try to do something clever with PATH definition here, a very simple solution would be to do something like this (unproven because I'm not on Windows but)
C:\Python2.7\bin\python.exe your_script_for2.7.py (make sure you are pointing to the right path of python.exe) and for 3.x
C:\Python3.x\bin\python.exe your_script_for3.x.py
What you're experiencing is probably the latest python installed, replaced the global python executable. You should be able to use python2.7 or python3.x as well though.
Me too had similar problem in windows, i was having python 3.5(and its path set in environment variables), so i installed python 2.7 from their site.then i did the following to start sqlmap
1) Got inside the folder of python 27 in cmd
2) executed the following command
python.exe "path to sqlmap-dev\sqlmap.py"
I have an account on a Linux server which currently has Python2.4 installed on it so by default running the command which python returns /usr/bin/python
I have installed Python2.7 in my account home directory # /path/to/myaccount and have set and sourced the path in my .bash_profile file as
PYTHONPATH=/path/to/myaccount/bin/python
export PATH=$PYTHONPATH:$PATH
However I am still getting Python2.4 as my default Python.
PYTHONPATH tells Python where to look for modules and packages (.py files etc)
You need to make sure your shell is looking in the right place for the Python binary
export PATH=/path/to/myaccount/bin:$PATH