Removing python and then re-installing on Mac OSX - python

I was wondering if anyone had tips on how to completely remove a python installation form Mac OSX (10.5.8) ... including virtual environments and its related binaries. Over the past few years I've completely messed up the installed site-packages, virtual-environments, etc. and the only way I can see to fix it is to just uninstall everything and re-install.
I'd like to completely re-do everything and use virtualenv, pip, etc. from the beginning.
On the other hand if anyone knows a way to do this without removing python and re-installing I'd be happy to here about it.
Thanks,
Will

Just for everyone else's reference. I found this in the Python documentation here:
Mac OS X 10.5 comes with Python 2.5.1 pre-installed by Apple. If you wish, you are invited to install the
most recent version of Python from the
Python website
(http://www.python.org). A current
“universal binary” build of Python,
which runs natively on the Mac’s new
Intel and legacy PPC CPU’s, is
available there.
What you get after installing is a
number of things:
* 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/.
I removed these and the virtualenv directories. Then I re-installed everything and its working fine now.

You should be able to delete the packages you've installed from /Library/Python/2.*/site-packages/. I do not think any package installers will install by default to /System/Library, which should save you from needing to remove Python itself.
That said, you could also use virtualenv with --no-site-packages, and just ignore whatever packages you've installed system-wide without needing to remove them.

Related

how to make anaconda use my default python?

how to make anaconda use my default python?
Useful infos
I'm working on 2 pcs one having win10 and the other having a fresh win 11 pro installation.
alongside anaconda I'm using VScode to develop in python, Django, PHP, laravel, js, react. and help me synchronize my settings between both pcs
I installed python3.11 and everything is well configured with VScode (database connection, etc), I also installed pipenv
main
as u see I have 2 python environments already installed
I want to remove the python installed in anaconda and I found a way to do so(I will explain it)
but I don't know how to make anaconda use my global python located in Program Files\python311
however, anaconda has a lot of packages, and I don't know if replacing thepy3.9 installed with them by the systems py3.11 will work or not
removing the python package from anaconda
First of all, where did you get Python 3.11 from ? If it was from the built-in App Store from Microsoft, you should deinstall it. This installation is buggy as hell, and you should consider getting 3.11 from somewhere else.
Secondly, Anaconda will manage the packages for you, so you should install Anaconda once with 3.11 and re-download all the packages you need.

What can I expect to change about how I write python on my Mac after I install conda?

Background
Currently, I have Python 2.7.17 and Python 3.8.1 installed on my Mac (v 10.14.6). Both Python versions were downloaded directly from Python.org using a "macOS 64-bit installer" .pkg file, in late 2019. Both were installed here:
python2: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2
python3: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
Currently, I use only pip (either pip2 or pip3, depending) to install python packages, which are saved here:
python2: /Library/Frameworks/Python.framework/Versions/X.X/lib/python2.7/site-packages
python3: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
I am about to begin an online course which requires that I install miniconda in order to install the packages that I need for the course. But after having a very bad experience having Anaconda installed on my machine years ago, and it taking me months to remove it and re-create a clean Python install, I am nervous. I don't want my machine to become a mess again, rife with error messages that it can't find this or that python version or this or that python library.
Question(s)
Assuming there will now be multiple installations of Python on my machine (in addition to the versions that I already have, since I believe yet another version of python is installed along with conda), and there will be new places where python packages will be saved, what can I expect to change about how I write python after I install miniconda?
Is there anything I will need to do differently from what I am doing now when I write python code?
How can I ensure that everything remains working and compatible and I avoid the fate I suffered many years ago?
Happy to edit/clarify this question per user suggestions. Thanks!
Use conda environments and install Python into those environments. This ignores, by design, the versions of Python that are installed at the system level. Also, what's installed into environments (other than the one you're in) is ignored. As somebody who uses conda for all Python development, I don't even know what I have installed in /usr/local/bin/ or other places. Everything is in /path/to/miniconda3/envs/env_name_n. You don't have to uninstall other versions of Python you have elsewhere; the point of environments is to keep everything isolated.
What can I expect to change about how I write python after I install miniconda?
Is there anything I will need to do differently from what I am doing now when I write python code?
Use conda environments and use conda as your package manager. For almost every major project, it nearly a drop-in replacement for pip. Outside of managing dependencies, not much changes.

Duplicate Python Installations

I had a manual installed python 2.7.5 version.
And since I need to use some statistical packages, I found anaconda to be more convenient, and installed anaconda, which include python 2.7.6
I have the following questions:
do I essentially need to remove/uninstall the previous manually installed version to avoid potential dependency problems?
Was trying to remove, but not successful so far, any hints? I followed suggestions on this board: How to uninstall Python 2.7 on a Mac OS X 10.6.4?, but find no luck yet.
will the previously downloaded/installed packages still work in anaconda, e.g., I launched NLTK in anaconda's python, and the previously downloaded corpuses are still there installed?
You should use virtualenv. Virtualenv allows you to create a virtual python environment for each project, so you can have different libraries for different projects, this includes different python versions.

Remove preinstalled python from Mac OSX 10.8

I want to move to python 3.0 and therefore remove the default python 2.7 (2.6,2.5...) installation on my mac. Including all the installed packages, $PATH,...
Does the python installer from python.org oder MacPorts installer provide an uninstaller, or is there a way to do this manually?
That's a COMPLETELY TERRIBLE idea, and you should never do that. You're likely to break dependencies and requirements for various software that expect to find the default Python in the default location.
Install your choice of Python 3 ( MacPorts, Python.org, whatever ). Update your local $PATH variables to use that Python / PythonPath.
If you don't trust my opinion, here's what official Python.org docs say:
http://docs.python.org/2/using/mac.html
The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.

I am installing python 3 on snow leopard, what am I installing exactly?

I'm having difficulty installing python 3 on snow leopard.
I'm having difficulty because I have no idea what I am installing. (I do understand that python is a language, and that it uses a virtual machine)
Where can I get an overview of all the parts that make up working installation of python and how they need to be configured?
I want to understand this so that I can use python 3, but not break the other installations on my system.
There is normally no need to build Python on Mac OS X from source. If you want the most recent Python 3, download and install one of the two official Python 3.2 installers for OS X from python.org here. The Python installers from python.org install a framework build of Python 3 rooted at
/Library/Frameworks/Python.framework/Versions/3.2
In that directory, you will find bin, lib, and other directories unique to that version. If you install another Python versions (say, 2.7) using python.org installers, it will be be installed under /Library/Frameworks/Python.framework/Versions/2.7, completely independent of the 3.2 version. There will also be a version of IDLE.app and other files installed into /Applications/Python m.n (3.2, 2.7, etc.). The Apple-supplied system Pythons (2.6.1 and 2.5.4 for OS X 10.6) are installed in:
/System/Library/Frameworks/Python.framework/Versions/
again a completely separate location. Thus, the system Python files do not need to be and should not be altered or removed. The python.org installers have the option to alter your shell PATH variable to prepend the appropriate framework bin directory to your path so that the newly installed Python will be found first. With Python 3 there is no conflict anyway, since you need to invoke it by python3, rather than python.
The python.org installers also have the option to install symlinks from /usr/local/bin to the important files in the framework bin directory but, for various reasons, those are not particularly useful. In general, you need to include the framework bin directory in your execution PATH; with that, the /usr/local/bin symlinks are usually not needed.
If you are really interested in the details, download the source tarball and examine configure.in and the top level makefile. The script that is used to build the installer is in Mac/BuildInstaller.
For additional information about Python on Mac OS X and the use of Tkinter, IDLE, and Tcl/Tk, see this page.
Go to Python.org
Download the source
Unpack
Follow the steps in the README (see below)
It will install to python3 by default thereby not breaking your other distros.
On Unix, Linux, BSD, OSX, and Cygwin:
./configure
make
make test
sudo make install
This will install Python as python3.
You can pass many options to the configure script; run "./configure --help" to
find out more. On OSX and Cygwin, the executable is called python.exe;
elsewhere it's just python.
On Mac OS X, if you have configured Python with --enable-framework, you should
use "make frameworkinstall" to do the installation. Note that this installs the
Python executable in a place that is not normally on your PATH, you may want to
set up a symlink in /usr/local/bin.
On Windows, see PCbuild/readme.txt.
If you wish, you can create a subdirectory and invoke configure from there. For
example:
mkdir debug
cd debug
../configure --with-pydebug
make
make test
(This will fail if you also built at the top-level directory. You should do a
"make clean" at the toplevel first.)
--
You are installing packages and modules. You can download the source and look through the directory. Everything installed is as it appears. This is not Windows where files are spewed everywhere on the system.

Categories