Python 2.7 not loading in Cygwin - python

I'm having an issued getting my install of python27 to load correctly in Cygwin. My install has 2.6 (/bin/python# ) on it, but I'd like the default Python environment to be 2.7 (/cygdrive/c/Python27/python.exe). I know how to change my $PATH and all, but when I try to run this 2.7 installation through Cygwin by going to its directory and typing python it never loads; I have to end the command with CTRL-c. Is this a Cygwin problem, a Windows problem, or a me problem?

I think you can find some answers in this other question.
It is rather a problem of using the Windows version of Python with the Cygwin terminal.
Quick summary:
for interactive mode, add the -i option
if you want to see the output of your script, add the -u option.

I faced the same problem with Python 2.7 on Cygwin. Launching Python with -i option did get me to the interpreter, but it would not allow the use of the "up" cursor key to repeat older commands.
What you need to do is to launch the /bin/bash.exe from a DOS prompt. This will launch the standard Windows console instead the Cygwin console.
This answer sums it up pretty well.

Related

python27 and python3 are not not recognized as an internal or external command, operable program or batch file [duplicate]

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.

How can I install “Python Editor” on “Ubuntu Bash” in Windows 10?

I'm trying to install a "python editor" that I can use for the Python 2.7 installation I've done via Bash Ubuntu in "Windows 10".
I beleive that the trick is to get a connection between "windows 10" desktop and the bash Ubuntu environment.
Hope someone has solved this and can help.
More info about "Bash on Ubuntu on Windows":
http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
I was looking for a solution to this "issue" as well. (I think) The problem is that the WSL(Windows subsystem for linux) has a different python interpreter than windows.
So when you try to run the same file from the editor and the bash terminal you would actually use two different version of Python to run the program.
It seems there is work being done to integrate the WSL and VSCode Which is I think a solution to your question.

Python 3.5.2 can be accessed through Terminal, but IDLE for 3.5.2 is missing

I am just getting started with Python and computer programming in general, so hopefully someone can help me out. I am trying to use PyQt4 to start learning how to code GUI's, and eventually use py2app to bundle these GUI's into Mac Applications...
The issue I am having is I just installed PyQt4 (or so I thought) on my computer, using MacPorts (http://www.pythonschool.net/pyqt/distributing-your-application-on-mac-os-x/). When following the guide, I did slightly modify the code I entered into terminal. At first, when I typed the sudo port install py33-pyqt4 command into Terminal, it returned
Error: Port py33-pyqt4 not found
So, I changed the command to sudo port install py35-pyqt4, which successfully installed python 3.5.2 along with PyQt4. When I type python3.5 into Terminal, Python3.5.2 loads, with PyQt4 working as well. I am able to import modules from PyQt4. Not sure if changing the command to install python 3.5.2 is what cause my issue.
The issue is this: I am unsure how to use IDLE (or another IDE, PyCharm for example) with python 3.5.2! I cannot find an IDLE version for python 3.5.2 on my computer. I do have python 3.5.1 and python 2.7 installed, along with their respective IDLE programs. PyQt4 modules, however, cannot be imported when I use these IDLE versions.
When I issued the sudo port install py35-pyqt4 command, did it install IDLE somewhere? Am I able to use PyCharm with python 3.5.2, if python 3.5.2 loads properly into Terminal? I just need some way to edit scripts outside of Terminal. Hopefully this is a clear enough question!
UPDATE:
I found the IDLE program... Realized that it was installed through MacPorts it is located in a MacPorts folder in my Applications folder. The only issue it that it will not open. Frustrating.
I also have IDLE programs which won't start. Not sure why.
If you are willing to use PyCharm, I would recommend that to you anyway. You can change the pythonpath in the PyCharm Settings -> Build, Execution, Deployment -> Console -> Python Console -> Python interpreter. Select here the appropriate Python binary.
If you are unsure about the pythonpath, type
which python3.5
in a terminal which should give you the path.
With that, PyCharm uses this Python version as your default.

python 3.2 installed, but MAC didn't recognize it

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"

Installed python3, getting command not found error in terminal

I installed python3, I can open idle and it says it is running python3.0.1, but when I enter python3 in the terminal (on OSX) I get an error saying 'command not found'. Entering python gets me the 2.x version that came on the computer. Any advice on how I can access python3 from the terminal?
Thanks
First, don't use Python 3.0.1. It has many problems and was officially retired upon the release of Python 3.1 (currently 3.1.2). You can find the python.org Mac OS X installer for 3.1.2 here. Once it is installed, then you need to ensure that the bin directory from the 3.1.2 framework (/Library/Frameworks/Python.framework/Versions/3.1/bin) is on your shell search path. You can manually modify an appropriate shell startup file, like .bash_profile. Or just double-click the Update Shell Profile.command found in /Applications/Python 3.1. In either case, you will need to open a new terminal window or re-login. Another approach is to install Python 3.1 from MacPorts or another distributor. Also, alpha releases of Python 3.2 are now available from python.org and elsewhere.

Categories