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.
Related
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.
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.
It seems I have several Python versions installed on my Mac (High Sierra). Do I really need more than one each of Python 2.7 and the most recent Python3?
I am primarily concerned about confusion when adding modules to the environments.
Here are the python executables I can find, excluding symlinks. Do I need them all? Does Apple need one version just for the OS? (Maybe that's Ruby I'm thinking of._)
/usr/bin/python
/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/Cellar/python/2.7.13/bin/python
/usr/local/Cellar/python/2.7.13/share/python
/usr/local/Cellar/python/3.7.1/libexec/bin/python
On MacOS, you need to have the system-installed Python 2 in /usr/bin/python because some system functionality depends on it.
If you have other versions installed via Homebrew or etc, that's strictly optional. For developing code in Python, definitely install a recent version of Python 3; you should not be developing new code in the legacy version 2. It will run out of support in a year or so, and many important third-party libraries etc have already abandoned support for it.
If you do need to maintain Python 2 code, having a Homebrew version of the most recent Python 2.7.13 is probably a good idea. The system /usr/bin/python is at version 2.7.10 as of MacOS Mojave; and if we extrapolate from Apple's update policy history for third-party open-source software in the system, it will probably remain there for many years.
Homebrew is just one of many ways to install additional Python versions, but since this is what you seem to be using already (as indicated by the /usr/local/Cellar paths) I will not go into alternatives.
For switching between versions, virtualenv is the common baseline, though there are many add-ons like pyenv etc which add convenience features or alternative models for switching between projects which require different versions of Python and various packages.
Note: this answer might be primarily based opinioned.
First, in macos, I encourage you to use brew to install python. So, if you want to instal Python 3 run:
$ brew install python
Probably it is already installed, so to update it run:
$ brew upgrade python
This will upgrade to the latest version of Python 3. In general, if you start a new project you should use Python 3. Remember that Python 2 will be deprecated at the end of this year 2019.
Second, I highly recommend you to use virtual environments to avoid having issues with dependencies. You can create a virtual environment running:
$ python3 -m venv .ven
This will create a virtual environment in .venv in your current working directory.
As an alternative you can use pipenv to track dependencies too which I also encourage you to install using brew.
$ brew install pipenv
Then you create a virtual environment running:
$ pipenv --three
Keep in mind that you will have two versions of Python in your machine python which is Python 2 (installed by default in your machine) and python3 which is Python 3. Then, if you want to run Python 2 just type python, while if you want to run Python 3 type python3.
Finally, you can also keep track of several python versions using pyenv. This is very useful if you need to use multiple versions of Python for example Python 3.1, 3.2, 3.3..., 3.6, 3.7.1, 3.7.2, 3.7.3, etc.
This is what has been useful in my experience using macOS. You could also use Docker to completely isolate your environment, but probably the first two points is enough if you are a beginner.
While Python 3.x is what python solutions should be implemented in today, many existing python applications, modules, etc, are implemented and maintained in 2.7 or lower. Sometimes you'll find multiple versions of python on your computer because applications you've downloaded in the past had you install them so their application would work properly on your machine. As long as you don't want, or need applications that may depend on past versions of python, you can update to the latest one and delete the old versions.
If you are planning on developing in python, and you can use the latest version, you should definitely do so. If you rid of the versions of python on your machine, applications, modules/scripts, etc may not work or function properly.
Python comes pre-installed on Mac OS X, but it is not required to be on your machine for your computer to function, just the applications that may be on your machine that may use Python.
I have installed iPython using pip in OS X 10.10, and it gave me the "ipython" and "ipython2" commands, which run great, but which use OS X's default python version 2.7.9. I downloaded and installed the latest release of Python3.4 and can load it with the command "python3," but cannot find a way to get iPython to use this version of python. The iPython Web site states the package can be used with python versions 3.3 and above, but I cannot find any instruction on how to change the default python version used.
So far I have found that the jupyter package for iPython has a kernel specification in /usr/local/share/jupyter/kernels/, which is just a folder called "python2" containing a json file that points to the system's python 2.7.6, but altering this to point to the new python3.4 installation does not work. My guess is this configuration is for the ipython notebook.
I've also tried the approach here: ipython reads wrong python version
In doing so I've duplicated the ipython2 command in /user/local/bin/ and edited it to use the python3 interpreter located at /Library/Frameworks/Python.framework/Versions/3.4/bin/python3, however, this gives me an error "ImportError: No module named 'IPython'," which suggests the python3 installation does not have ipython installed.
To tackle this, I've tried uninstalling ipython and reinstalling it using pip, but it just targets the system's Python 2.7 installation and does nothing for python3.
Does anyone know how to configure iPython to use a different python version, or even install a separate ipython installation for python3? Ultimately it would be nice to quickly switch back and forth depending on my needs.
I just found the answer. In essence, this stems from not understanding the python installation layout and how resources are separated between installed interpreters. It appears each python version will have its own repository of tools, and the current "pip" command I had installed on the system was mapped for use with python 2.7, so all libraries, tools, and other details it managed where available only to python 2.7. This included iPython.
I thought that installing python3 would make all these libraries available to the new interpreter by default, but it appears the system keeps them all separate (which makes sense). The main issue here was continuing to use "pip" which targeted the old installation, instead of the new "pip3" command included with python3. By using pip3 to reinstall iPython, I was able to get iPython3 installed properly.
Unfortunately this setup means needing to re-download other libraries, but that's not too difficult.
It might seem like a trivial issue in hindsight, but this had me completely stuck. I hope this helps someone else in this situation.
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.