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
Related
my problem is before I installed Anaconda, my python with python and py commands shows the same versions. After I installed Anaconda, my python version is using Anaconda installation. How to prevent this, because I don't want to use Anaconda python version on my Windows.
I already put my python PATH on the top
When I check the PATH, there's no anaconda PATH anywhere when I done my installation
My python version will use the default python version, not the Anaconda's version
You need to change the default opener for the .py files on your computer.
try to right-click on the .py file, select "open with" and look for python.
You can always use cmd and run the following:
python <path_to_file>
or
python3 <path_to_file>
It depended on your python version
(as long as you set your python path in windows Path)
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.
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.
I'm having some problems upgrading Python on my Mac. For my first attempt, I downloaded and installed the 2.6.4 dmg MacPython installer from http://python.org/download/mac/. This did install 2.6.4, and when I ran 'python' from the terminal it says that version.
However, I also had a test script where I am doing:
import os, json
But I get an error that the 'json' library was not found. In the script I included this shebang at the top to make it run from the terminal:
#! /usr/bin/python
I suspect that the symlinks that come directly from Apple that point to Python 2.5 were not updated by the 2.6.4 installer, so directly from the terminal 'python' is running the newer version, but my test.py file is executing 2.5.
So at this point I read a couple of other SO pages on doing this upgrade, and people recommended using 3rd party packages that sit side-by-side so as not to break the OS-level dependencies on v2.5. I then found ActivePython offered a 3.x installer(that was also recommended on another SO page). I installed that, but 'python' still shows 2.6.4 and my script still can't find the json library.
Finally, I'm baffled at how to safely remove MacPython( the Mac installer I mentioned above ). There's one sentence on the page that says to remove some things that seem pretty vital to Python on the Mac. Quote:
A MacPython 2.5 folder in your Applications folder. In here you find IDLE, the development environment that is a standard part of official Python distributions; PythonLauncher, which handles double-clicking Python scripts from the Finder; and the “Build Applet” tool, which allows you to package Python scripts as standalone applications on your system.
A framework /Library/Frameworks/Python.framework, which includes the Python executable and libraries. The installer adds this location to your shell path. To uninstall MacPython, you can simply remove these three things. A symlink to the Python executable is placed in /usr/local/bin/.
So now I have 3 versions of Python installed and I'm not sure how to resolve this stupid mess.
First, /usr/bin/python should always point to the Apple-supplied python and on 10.5 that means python2.5. Don't change this!
When you installed the python.org python2.6, by default it installs symlinks in /usr/local/bin/ so one way to invoke it is /usr/local/bin/python2.6 or, most likely, just python2.6. Since json was added to the python library in python 2.6, you'll find the json module is there. One way to solve your orignal problem then is to change the shebang line to be:
#!/usr/bin/env python2.6
Also by default, the python.org installer updates your shell profile to add its bin directory to your $PATH, which is why typing python probably now invokes python2.6.
You shouldn't need to but if you really want to remove all traces of the python.org 2.6:
Delete the extra lines at the end of your .bash_profile and/or .profile by reverting to .bash_profile.pysave and .profile.pysave.
Remove the python2.6 framework directory:
sudo rm -r /Library/Frameworks/Python.framework/Versions/2.6
Remove IDLE and the extras installed in /Applications:
sudo rm -r /Applications/Python\ 2.6
Also there's nothing wrong with moving on to Python 3. For the moment, both Python 2 and Python 3 are being actively developed; search the archives for the various pros and cons. However, Python 3.0 should not be used. Not surprisingly for something that major, Python 3.0 had a number of serious first-time bugs so, with the release of Python 3.1, 3.0 support was immediately dropped.