How to install/run Python on a Mac - python

After giving up on doing a disk partition and getting Linux, I decided to try and install Python 3.3.2 on a 32 bit Intel Core 2 Duo iMac with OS X 10.6.8 Snow Leopard. I did pretty much everything the official website says, but it isn't working at all.
First of all, I downloaded the installer for Mac OS X 6 and later, which should supposedly put a folder called MacPython 3.3 with IDLE, PythonLauncher and a Build Applet tool in my Applications folder. What I have instead is a folder called Python 3.3 which does contain (aside from the documentation and a command to update shell profile) IDLE and PythonLauncher, but no Build Applet tool; I typed 'python' into my Terminal window to see if 3.3.2 was installed, but it said Python 2.6.1 even after restarting my computer. The ReadMe in the disk image that contains the installer says running the installer should also 'put the underlying machinery into the folder /Library/Frameworks/Python.framework'. I did every search imaginable and apparently there is no such folder anywhere in my hard drive.
Basically, I want to install 3.3.2 and run things in programme mode rather than shell mode, which I find to be a huge pain in the bottom. Any help is greatly appreciated.

You don't need to download or install any software.
Just write your code in your preferred text editor, and save it as a anything with .py at the end. Next, go to a terminal and type in python *****.py, where ***** means whatever your file is named.

Try typing 'idle python3.3' or something similar in the terminal.

Related

Can't run python on windows anymore

Since the most recent update to Windows 10, I have been seeing this message every time I try to do anything with Python
I have reinstalled it, tried running it as administrator. Nothing works.
First make sure that python.exe exists in the given directory and that its not a zero-length file. More likely though is that you installed the wrong version of python. Make sure you download and install the x86 version as it will work on both 64-bit and x86 systems. Do a full uninstall and install python via the Windows x86 MSI installer.
Edit:
If this doesn't work please provide more information on which specific Windows 10 version you are running and which python installer you are using.
Edit 2:
You can also get more information from the Windows Event Log
I think the reason is that python.exe has size 0 Kb. It could happen because you (and me too) didn't exit from Python correctly.
The way to fix the issue is to re-install Python or download "portable" version:
https://www.python.org/downloads/release/python-385/
By the way, one of the way to exit from python (v3) in Windows:
>>> import sys
>>> sys.exit()
I've also had "This app can't run on your PC" windows 10 dialog box starting to appear after I tried to start x64 app from python script under x86 python.
Uninstalled x86 python, installed x64 python and all started to work normal.
I didn't have to reinstall Python.
python.exe inside my env\Scripts\ became 0kb for some reason. So I created another virtual-env and copied python.exe from there to this folder. Then it started working.

Setting up python on external HDD (on MacOS)

I don't have access to current portable python solutions, and I'd like to put a bare bone python and manually add libs on an external HDD using a Mac.
I went to python.org but the .pkg file for Mac automatically installs python locally. I am wondering if there is a solution to what I am trying to do.
The .pkg installer clearly gives the option Change Install Location...:
Try clicking the button and selecting the external drive.

I installed Python 3.4.3 over 3.4.2 on Windows 7... and now I cannot uninstall Python

I installed Python 3.4.3 over 3.4.2 on Windows 7 and got problems with IDLE not starting.
When I use the Windows uninstaller via the control panel I get the message:
"There is a problem with this Windows Installer package a program required for this install to complete could not be run. Contact your support personnel or package vendor."
If I try to remove Python via the msi file then I get the same message.
There is no Python34 directory on my machine. I noticed that there is an entry in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Modules. I didn't want to mess with my registry, but can I safely delete this entry? Is there any more to delete?
I used MicrosoftFixit.ProgramInstallUninstall and I was able to remove Python34 and then it reinstalled without any problems.
Had a similar problem. This is what I did:
Restart computer (kill any running processes of Python)
Delete the main Python folder under C drive.
Using CCleaner (or a similar application), use the Tools -> Uninstall feature to remove Python (if it is still there after deleting the folder)
Then go to the Registry window in CCleaner and clean the registry. Python should now be completely gone from your computer.

how to compile a python .app from ubuntu or windows

I am still very new to Python and any freezing programs.
Recently I made a very short text adventure game I'd like to send to a few friends, most of whom have Snow Leopard. I don't want them to have to bother downloading python just to play the game though.
Is there a way to convert my game from Ubuntu so that it is playable on Mac? That is, make an .app file from ubuntu? Or even from Windows, I suppose.
I tried using cx_freeze on Windows but that just compiles an exe which is not playable on Mac.
Thanks for any help and suggestions.
EDIT: I am using Python 3.2.2. I think Macs come standard with an older version else there would be no problem just sending them the game, I imagine.
As far as I remember, last I used Mac OSX, it already had Python installed. This was with Mac OSX Snow Leopard.
No need do compile to a native binary if you can run your code through Python on any machine.
Your code could run in Python 2.6, the default which comes with Snow Leaopard, unless you used version 3 specific features. Try if it does. If so just package your code so it runs the .py through python /path/to/code.py
You can also make your .py file self-executable with a shebang first line,
#! /usr/bin/env python
# this should be the first line in your .py file
and setting the file executable flag, perhaps through your packager on installation:
$ chmod +x code.py
You will notice shebang does not point to a specific python binary like /usr/bin/python, but to the /env environment path, so it will use the default interpreter on whichever machine it is run on.

Python 3.2 doesn't work with python 2.7

I already have python 2.7 (installed using activepython). I'm trying to use python 3.2 just to learn more about it so i downloaded it from python.org
python 2.7 still works perfectly, but python 3.2 gives me this error when i try to open the ide.
and then I see the send error window, if i install python 3.2 using activepython i see the same error.
I'm using windows xp pro sp3 32 bit and i had the same error on sp2... How do I fix it?
EDIT #Zuljin
This is the first time that i use dependancy walker so could you give me a hand please
this is what i see
what does that mean? I already have these files...
I saw a lot of answers here. But, I think the file that you are trying to run is not correct
C:\Python32\Pythonw.exe
is not the one you use to open idle.
Open
C:\Python32\Lib\idlelib\idle.pyw
Python 2.x and 3.x can cohabitate perfectly in win xp and win 7, either 32 or 64 bits.
If you first installed the ActiveState Python distribution, be careful when installing python-3.2.2.msi.
When you arrive to the customize python 3.2.2 screen, (un)check 'register extensions' to make the feature unavailable (that is: do not register extensions).
I have installed this way both distributions in different computers without any problem so far.
Note: Check your environment variables. Only python 2.7 should be in the path (if you installed before the two distros you could have them both in the path. Remove python 3.2 path)
Edit:
From Ankit post I realized that in fact you were trying to open IDLE, maybe.
If you follow my installation instructions when you call idle.bat from the py3.2 idlelib folder you actually get idle for python 2.7 as this is what the call find in the windows path. To be able to open idle for py3.2 in the presence of python 2.7 as the registered python, I use a .bat file modified from that in the distribution:
idle_stay.bat
#echo off
rem Working IDLE bat for Windows - Custom bat for py3k as secundary python
C:\Python32\pythonw C:\Python32\Lib\idlelib\idle.pyw %1 %2 %3 %4 %5 %6 %7 %8 %9
The name idle_stay.bat is because I put this file in the folder where the official idle.bat is (C:\Python32\Lib\idlelib\idle_stay.bat). In this way it does not get overwritten each time I unisntall and reinstall a new version of python 3
It seems to me you have associated a *.py or *.pyw file extension type to some version of python.exe and/or pythonw.exe you aren't clear about. This is often, but not exclusively done from within Microsoft's "explore.exe" File Manager (I believe in Options).
I disagree that this is a reliable method:
C:\Python32\Lib\idlelib\idle.pyw
as this method will run whichever program is assigned to the "pyw" extension. That could be:
C:\Python32\pythonw.exe
or
C:\Python26\python.exe
or whatever might have happened to your file extension association as per OS or bad PATH environment variable setting. It is better to do something like this:
C:\Python32\pythonw.exe C:\Python32\Lib\idlelib\idle.pyw
where you are explicidly telling the OS to run the python executable from a specific path and selecting a specific python script in the file/folder hiearchy.
Another thing you can try to gather info is just:
python.exe -V
which will tell you the version number.
Another thing you can do:
Open a DOS command prompt and type:
set PATH=C:\Windows;C:\Windows\system32;C:\Python32
python.exe and note the version and whether is runs.
exit()
exit
Once working debug your PATH. You can use this Python script to gather intel.
If you turned off your WinXP findfile stuff (like I have) you can use this script:
inpath.py can help shed some light.
Run this python script like this:
Drop to a DOS prompt
cd to your folder with a working python.exe version.
and type python.exe inpath.py python*
where inpath is in that same folder for this test/debug.
inpath.py will search your path for all files associated as "runable" in your OS and that is in your "PATH" with the python*.* pattern.

Categories

Resources