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"
Related
I want to install dlib but since it only supports python 3.6, I have to downgrade my python 3.7.
I was able to create an environment and already selected it on my VSCode but whenever I check my terminal for the python version, it's still stuck on 3.7.
Can someone help me on this?
When you write python in the terminal, the version used is resolved by the PATH variable. You may want to specify the full path to the Python version you want (in Windows, use where python to list all possibilities), or modify the PATH variable and change the order. Depending on the installation method, the full path to python may look like C:\Python36\python.exe
I am using Python 3.5.2 version on Windows 7 and tried using python3 app.py. I am getting this error message:
'python3' is not recognized as an internal or external command,
operable program or batch file.
Is there any specific cause about why the python3 command is not working?
I also verified that the PATH is added to environment variables.
There is no python3.exe file, that is why it fails.
Try:
py
instead.
py is just a launcher for python.exe. If you have more than one python versions installed on your machine (2.x, 3.x) you can specify what version of python to launch by
py -2 or
py -3
You can also try this:
Go to the path where Python is installed in your system. For me it was something like C:\Users\\Local Settings\Application Data\Programs\Python\Python37
In this folder, you'll find a python executable. Just create a duplicate and rename it to python3. Works every time.
Python3.exe is not defined in windows
Specify the path for required version of python when you need to used it by creating virtual environment for your project
Python 3
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
Python2
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
then activate the environment using
.\environment\Scripts\activate.ps1
Yes, I think for Windows users you need to change all the python3 calls to python to solve your original error. This change will run the Python version set in your current environment. If you need to keep this call as it is (aka python3) because you are working in cross-platform or for any other reason, then a work around is to create a soft link. To create it, go to the folder that contains the Python executable and create the link. For example, this worked in my case in Windows 10 using mklink:
cd C:\Python3
mklink python3.exe python.exe
Use a (soft) symbolic link in Linux:
cd /usr/bin/python3
ln -s python.exe python3.exe
In my case I have a git hook on commit, specified by admin. So it was not very convenient for me to change the script (with python3 calls).
And the simplest workaround was just to copy python.exe to python3.exe.
Now I could launch both python and python3.
If python2 is not installed on your computer, you can try with just python instead of python3
For Python 27
virtualenv -p C:\Python27\python.exe django_concurrent_env
For Pyton36
virtualenv -p C:\Python36\python.exe django_concurrent_env
Enter the command to start up the server in that directory:
py -3.7 -m http.server
I had a related issue after installing windows 11, where python3 in cmd would open the windows store. I was able to sort it out between this post and this other one. In short, I reinstalled python and made sure to add it to PATH. Then, in settings, Apps > Apps & Features > App Execution aliases. Here, all I had to do was make sure that every single python .exe (including idle and pip) were turned off EXCEPT FOR the python3.exe alias. Now it works like a charm.
FWIW:
The root of this issue is not with you or with python. Apparently, Microsoft wanted to make installing python easier for young kiddos getting interested in coding, so they automatically add an executable to PATH. For those of us that already have this executable, it can cause these issues.
Found out instead press the play button the top right and it should work in visual studios:
Do not disable according to first answer
Saying python3 in the command will not work by default.
After figuring out the problem with the modules (Solution): https://youtu.be/paRXeLurjE4
Summary:
To import python modules in case of problem to import modules:
Hover over python in search:
Click open in folder
Hover over and right click
click properties
copy everything in path before \python.exe
close those windows
For cmd (administrator):
cd --path that was copied--
then python -m pip install --upgrade pip
cd Scripts
pip install "Name of Package" such as pip install --module (package) --
Im on win10 and have 3.7, 3.8 and 3.10 installed.
For me "python" launches version 3.10 and does not accept commands (like -3.7), "py" launches newest version but does accept commands, and "python3" does nothing.
Uninstalled 3.10 and "python" now does nothing, and "py" launches 3.8.
I am unable to add a comment, but the mlink option presented in this answer above https://stackoverflow.com/a/55229666/8441472 by #Stanislav preserves cross-platform shebangs at the top of scripts (#!/usr/bin/env python3) and launches the right python.
(Even if you install python from python.org, Windows will direct you to the app marketplace nowadays if you type python3 on the command line. If you type python on the same cli it will launch the python.org version repl. It leads to scripts that generate no output, but more likely silently failed completely. I don't know ho common this is but have experienced it on a couple of different devices)
If you have this at the top of your script to ensure you launch python3 and don't feel like editing everything you own, it is not a bad approach at all... lol.
I bought my mac about a year ago and somehow changed my python symlink so that when I run python some_file.py, python 3.4 is used to run the file instead of python 2.7. I now need to change it back, but I can't figure out what I did to change it in the first place! When I run:
import os
os.path.realpath("/usr/local/bin/python")
in the python terminal, the output is:
'/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'
Does this not mean that my python symlink is pointing to my python 2.7 version, and not my 3.4 version? If not, how do I find out which file is run when I use the python symlink?
You probably installed that specific Python version using the official Python installer for OS X; see the Using Python on a Macintosh documentation. The installer creates the /usr/local/bin symlink for you.
If you also, at some point, had 3.4 installed then that installation is still there too. Check for a /usr/local/bin/python3 command; it'll link to the existing Python 3 binary. Use that instead to run Python 3 code.
If you do have a /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 command, you could re-create the /usr/local/bin/python symlink to point there instead, but I'd personally only use the python3 name for Python 3 scripts.
Last, you could also have used the homebrew tool to install Python; it can manage symlinks for you. However, homebrew installs Python binaries into the /usr/local/Cellar tree structure instead.
I have 2 versions of python installed on my server.
Python 2.6 in /usr/bin/python
Python 2.7.8 in /usr/src
Python 2.7.8 install guide
How do I make python scripts use 2.7.8? instead of 2.6?
how do I set up an alias?
Thanks
Write:
#!<path to your python interpreter>
as the first line of the script your run. Then just execute it.
Other option:
<path to your python interpreter> your_script.py
There are multiple ways of doing this. First, I would suggest you check your $PATH environment variable to see if it holds the path to both of your python versions. If it doesn't, you can either add the path or simply make a symlink to it from /usr/bin/ and call it python2.7, for example.
Then you can use #Pavel's suggestion of specifying the path to the interpreter in the shebang of the file.
If you followed my previous instructions, your shebang should look something similar to the following.
#!/usr/bin/env python2.7
You could also use the second way #Pavel showed you, by simply calling the interpreter first in the terminal and pointing it to the script.
/usr/bin/python2.7 my_script.py
The best option you have, which I recommend, is using virtualenv as suggested before, but only if you want it for specific scripts. If you want it globally, I would suggest you read further.
Finally, if you want all your scripts to run under python 2.7 then I suggest you remove python 2.6 and install the 2.7 version from the package manager, the right way, and save yourself a lot of hassle.
I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
Is python3.2 in your PATH? Try typing "python3.2" at the command line and see if that works. Where is python3.2 located? It's probably /usr/bin/python3.2 Try using that in WingIDE and see if that works.
This may depend on the version of OSX you are running. I did a custom install of python 2.7 on my machine running 10.6.7 and had to modify ~/.bash_profile with the following line:
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
You may want to check the directory /Library/Frameworks/Python.framework/Versions and see what the full path is to your 3.2 install. You could then modify the PATH variable in your ~/.bash_profile like this:
PATH="/Library/Frameworks/Python.framework/Versions/YOUR_VERSION_NUM/bin:${PATH}"
trying to fix wing myself, but if you want to just execute it via commandline...
in terminal:
python3.2 ./filename.py
enjoy
The reason is because the "python" shortcut doesn't exist in "/Library/Frameworks/Python.framework/Versions/3.4/bin", which is the newly created binary location.
Create a soft link to "python" as a work around.
"ln -s python python3.4".
Also, make sure that your .bash_profile has an entry for /Library/Frameworks/Python.framework/Versions/3.4/bin directory.
Verify with "Python -V"