I haven't used Python in a while, and only in Linux. Now on Windows, and just installed 3.7.4. I noticed immediately that python3.exe is not in the install directory, nor any of the pythonX.x.exe files, that are used for compatibility. I can only access Python through "python" from my command prompt, and old scripts that use Python 3 won't work.
Is there something I am missing here?
Of course, I can solve this for now by using symlinks, but is this an error in 3.7.4, or more likely, have I done something wrong in setting up my environment on Windows?
No, there's nothing wrong. This is just how Python is on Windows. There's the py launcher too that might help you out here.
https://docs.python.org/3/using/windows.html
3.2 The Microsoft Store Package
All three commands are also available with version number suffixes, for example, as python3.exe and python3.x.exe as well as python.exe (where 3.x is the specific version you want to launch, such as 3.7).
Virtual environments can be created with python -m venv and activated and used as normal.
If you have installed another version of Python and added it to your PATH variable, it will be available as python.exe rather than the one from the Microsoft Store. To access the new installation, use python3.exe or python3.x.exe.
Related
I installed Python 2.7 a long time ago on my PC (I am running Windows 10). Today I decided to install Python 3.7, but after typing 'python' into the command prompt the console printed 'python 2.7...'
I have no idea as to what I should do. Would this be a problem with my path configuration? I considered uninstalling python 2.7 but I still want it installed on my computer.
Configure multiple Python versions on Windows
Python 3.3 introduced the Python Launcher for Windows. Rather than using python.exe, call py and select the version with flags:
py -2.7
py -3
System-wide installations of Python 3.3 and later will put the launcher on your PATH.
Note on Virtual Environments (new in Python 3.5)
If the launcher is run with no explicit Python version specification, and a virtual environment (created with the standard library venv module or the external virtualenv tool) active, the launcher will run the virtual environment’s interpreter rather than the global one. To run the global interpreter, either deactivate the virtual environment, or explicitly specify the global Python version.
Outdated Method (not recommended)
Rename executables - After installing multiple versions, change the names of the executables. For example, for Python 2.7, under the installation folder, rename python.exe to python27.exe and rename Python 3.7 from python.exe to python37.exe. Then on the command line, select the version by entering python27 or python37. Whichever version is preferred, could be left as just python.
Add Path Environment Variables - For example, on Windows 10, go to the Windows menu and search for "environment variables" and click edit the system environment variables. In the System Properties dialog, click Environment Variables.... Under "System variables", select "Path". Click Edit.... Click New and add the first entry below. Click New again for each Path variable entry.
C:\Python27
C:\Python27\Scripts
C:\Python37
C:\Python37\Scripts
This will enable Python and pip. Be sure that paths match your actual installation directories.
I would suggest using pyenv
I have been using it and is working well for me. Some of the handy features of pyenv are
It allows installing multiple version on python easily
It allows switching python version with one command in global, shell or folder level
It also allows creating virtual env using virtualevn extension
I would suggest to use virtual environment. Soon or later you would you might get dependency problems.
You Can Configure The Python2 & python3 In Windows PC Like This:
First Of All Install Python 2 & Python 3 in windows PC in C directory like this:
C:\Python27 --> For Python2
C:\Python39 --> For Python3
After Installing Both Packages Go To Their Respective Folders And Copy python.exe & Paste In The Same Directory and rename the python - Copy with python2(In python27 folder) & python3(In python39 folder)
Python2:
Python3:
And Then Set Environment Vairable Like This:
All Done Now You Can Run Any Script Which May Compatible With Python2 or Python3 :)
I have an issue where somewhere along the line i've installed python3 and it has overwritten the default python path which is for 2.7. So when I go to terminal and type in "python" it loads version 3.6.5 instead of 2.7. If i type in "python2.7 to explicitly run python i get an error saying its pointing to the 3.6 site-packages instead of 2.7.
derekchan#PandaMacPro:~/python$ python2.7
Your PYTHONPATH points to a site-packages dir for Python 3.x but you are
running Python 2.x!
PYTHONPATH is currently: "/usr/local/lib/python3.6/site-packages"
You should unset PYTHONPATH to fix this.
I've viewed other threads on this issue but it doesnt solve or help my problem. Is this a simple PYTHONPATH issue?
I just want to be able to type in "python" and it load version 2.7 instead of version 3 and not have issue with the conflicting python packages.
Consider using a distribution like Anaconda with built-in package management. With Anaconda you can easily isolate your Python2 and Python3 environments and not have to mess with PYTHONPATH
https://anaconda.org/
I am using Windows 8 where I have Python 2.7 installed. In addition I have cygwin installed where I installed also Python 2.7.
I need to install a Python library whose installation on Windows is not supported but it is on Linux so I want to try to use it on Cygwin.
The library has a "configure" script who checks dependencies for many packages and settings and complaints because some python packages are not installed.
But when I try to install them, the system says they are installed. From this, I have concluded that my python windows installation is overlapping my python cygwin installation.
I think that the cygwin is importing in the Path all the windows Path and while the script checking the configuration can find the cygwin installation, when executing from the command-line it is not the case.
Of course, I don't want to remove from the PATH my windows python.
My question is then, what option do I have to work from cygwin only with the cygwin python installed?
As far as I have seen in other questions, usually the problem is the opposite (making cygwin to use windows python, what is problematic and not recommended in some cases).
Set the path in your .profile then.
So if e.g. your Python is in C:\Python27
remove the windows paths to /cygdrive/c/Python27 in .profile
E.g.:
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:
/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:
/usr/bin:/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/bin:/cygdrive/c/Python27:
/cygdrive/c/Python27/Scripts
=>
.profile:
export PATH=/usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:
/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:
/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn
I have python 3.2 installed and I want to know if I have to uninstall earlier versions before installing newer ones.
Install all the Python X.Y versions you want, but include Python 3.3 or later (last is best, or reinstall it after all the others) to get the Python Launcher that #abarnert mentioned in his comments. It is also available as a standalone installer.
Earlier versions than 3.3 should not register extensions, so the launcher installed by 3.3 or later will remain the default handler for .py files.
From the command line:
py -2 # launch latest 2.x version installed.
py -3 # latest 3.x
py -3.2 # run exact version
py -3.2-32 # run 32-bit version on 64-bit system.
So you can even have mixed 32-bit and 64-bit installations.
The environment variable PY_PYTHON can be set to specify the default Python to run.
In scripts, add a comment of the following forms below to use that version of Python when the script is double-clicked or run from command line via py script.py:
#!python2
#!python3
#!python3.2
#!python3.2-32
See PEP 397 for further details.
You can install multiple versions of Python on Windows, but only the last version you installed will be used by default: when double-clicking a .py file in Windows Explorer, when typing just python at the command line, etc. "Edit in IDLE" on the context menu also uses the last version you installed. To use other versions you'll need to specify the full path of the version you want. Also, if you use the PYTHONPATH environment variable, there's only one of those, and the scripts in the directories specified in PYTHONPATH may or may not work with whatever version of Python you happen to be running. This can be worked around by writing a batch file that sets PYTHONPATH before launching Python.
It generally depends on what OS you are running and how you installed your python. Under linux or Mac OSX, you don't need to unistall the previous version. I am not sure how things are handled for Windows.
I have Python 2.7.2 installed in the default location, C:\Python27.
I've downloaded pysvn 2.7 from http://pysvn.tigris.org/project_downloads.html > Windows installation kits. Pysvn Windows installer aborts on
pysvn requires Python 2.7 to be installed.
Quitting installation
I've tried both installer files, py27-pysvn-svn1612-1.7.4-1321.exe and py27-pysvn-svn1615-1.7.5-1360.exe. Neither of them works.
How can I convince the installer that I have Python 2.7 installed?
How is the installer determining whether pysvn is installed or not?
Did u perhaps install the 64-bit version of Python? If yes: Try the 32-bit installer.
Background: It seems like the 64-bit installer doesn't properly set the correct values in the windows registry (which is the place where PySVN tries to find Python).
I tried this and it worked perfectly:
Copy HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath to HKCU\SOFTWARE\Python\PythonCore\2.7\InstallPath.
Same link as above, but a different solution is offered within the thread. It is a problem with the pysvn 32-bit installer looking in the wrong (?) place in the Registry for the installed Python version.
Edit: The 32-bit module still didn't work correctly with the 64-bit Python. The only solution for this is to use 32-bit Python with the module.
Another option is to copy the the registry keys from HKEY_LOCAL_MACHINE\SOFTWARE\Python to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python
http://pysvn.tigris.org/ds/viewMessage.do?dsForumId=1335&viewType=browseAll&dsMessageId=2719385
My case was a bit different. Since my Anaconda install was for Python 3.6, no matter what I did I wasn't able to install PySvn (never got detected).
So since PySvn last release is for Python 3.5, I've created a conda env for Python 3.5.
Open Anaconda prompt and type: conda create -n *myenv* python=3.5
Then, open the win prompt and type regedit.
In regedit, under HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\ I changed the name of the folder from 3.6 to 3.5. Additionally, in HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.5\InstallPath I changed the value of Anaconda's default folder to my Anaconda's env folder (C:\ProgramData\Anaconda3\env\*myenv*).
Then I ran the installed and it worked fined. After installed, I remade the changes in the system registry to the original ones.
Now I can import Pysvn, inside my conda env, without any problems.