- The open-source Anaconda Distribution is the easiest way to perform Python/R data science and machine learning on Linux, Windows, and Mac OS X. With over 15 million users worldwide, it is the industry standard for developing, testing, and training on a single machine, enabling individual data scientists to.
- The first time I decided to download Anaconda, I went through the normal graphical Mac installation. It worked fine as an application, but it just wouldn’t work with my terminal. Unwilling to give up, I uninstalled Anaconda and then tried the command-line installation.
- Install conda by navigating to the Anaconda download page. Scroll down to the “Anaconda for OS X” portion of the web page. Download the Python 3.5 version by clicking on the “Mac OS X 64 bit Graphical Installer” link. It is a big download, so it is best to be on fast network.
The open-source Anaconda Distribution is the easiest way to perform Python/R data science and machine learning on Linux, Windows, and Mac OS X. With over 15 million users worldwide, it is the industry standard for developing, testing, and training on a single machine, enabling individual data scientists to. Quickly download 1,500+ Python/R data science packages. Dec 26, 2016 While I previously made a video on how to manually install anaconda, the way below utilizes bash scripts which are a faster way to install a Python.
- Latest Version:Python 3.8.0 LATEST
- Requirements:Mac OS X 10.6 or later
- Author / Product:Python Software Foundation / Python for Mac
- Old Versions:
- Filename:python-3.8.0-macosx10.6.pkg
- Details:Python for Mac 2019 full offline installer setup for Mac
Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm Handhelds, and Nokia mobile phones. The tool has also been ported to the Java and .NET virtual machines. The app is distributed under an OSI-approved open source license that makes it free to use, even for commercial products.
Some of its key distinguishing features include:
- Very clear, readable syntax
- Strong introspection capabilities
- Intuitive object orientation
- Natural expression of procedural code
- Full modularity, supporting hierarchical packages
- Exception-based error handling
- Very high level dynamic data types
- Extensive standard libraries and third party modules for virtually every task
- Extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
- Embeddable within applications as a scripting interface
Also Available: Download Python for Windows
Confusion and errors from many alternatives and options
- Folders Python on CLI
- Python 3 vs. 2
- Start a HTTP Server Using Python
- Upgrade Python
- Upgrade pip and setuptools
- Virtual Environments
- PIP (Python Installation Packager)
- Python 2 executables
- .bash_profile config
- Scripting Python versions
- Conda
This tutorial describes the different options to install anduninstall Python within variouspackage managers (which helps you find and install Python packages).
Here I’m taking a “deep dive” approach because I haven’t seen one on the internet.
I’ve pulled out the various incantations suggested by others on StackOverlowand put them here in context.
TL;DR Summary - It’s a mess
The version of Python that comes with Apple MacOS is obsolete and needs to be updated along with Apple XCode CLI for the MacOS version you’re using.
There are two separate versions of Python: 2 and 3. some Python functions in one version do not work with commands in another version.
This has given rise to several versions of Python frameworks being maintained in parallel. For example, the web application development framework exists as Django 1.3 and Django 1.0.
Adding to the confusion is that various methods of installing Python are incompatible with each other.This has given rise to the need for package managers such as pip (Python Installation Packager) that enable one to switch among different versions of Python installed.
pip (Python Installation Packager) is built on top of setuptools whichis what downloads and installs Python packages from the PyPI (Python Package Index) library online at https://pypi.org.
Setuptools itself is installed using easy_install.
MacOS does not come installed with a package manager for Python.
This complexity necessitates the packaging of whole virtual environments to isolatewithin a folder (directory) everything (all dependencies) that each Python project (application) needs to run.This means duplicated files for each Python application, which consume more disk space.
An additional complication is that there are several alternative virtual environment packagers such aseasy_install, virtualenv, and pipenv.
- pip (Python Installation Packager) is a package manager.
- Virtualenv (venv) is an environment manager for Python.
- Conda does both, and is language agnostic (not just for Python).
- Miniconda is a lightweight distribution of Conda, and uses conda commands.
- Anaconda is installed on top of miniconda to provide a curated collection of over 720 “common” packages for scientific Python users.
It’s a “hot mess”.
Despite all this hassle around versioning, Python is the preferred language of Artificial Intelligence and Machine Learning at the forefront of computer science innovation today.The heavy use of math in AI and ML by TensorFlow means it’s best to install Anaconda and use conda commands (instead of Miniconda or pip with virtualenv).
IPython (Jupyter) Notebook enables a “notebook” interface to re-run commands.See http://sjbyrnes.com/python/
PIP install is troublesome, often because they are more recent than those in Conda.
Python Install Options
There is what can be a confusing conflict of choice here for installing Python and its package manager.
- Not recommended is the manual approach of download Python installer from python.org, even though that’s the method described in various websites and books.
- easy_install is an environment manager.
One writes: “Avoid easy_install or pip to install a Python package that needs a library used by non Python programs, such as Qt bindings (PySide)”.
Alternatively, use a package manager. CAUTION: MacPorts, Fink, and Homebrew do not coexist well on the same machine.
- Install using Homebrew, then add homebrew science for scientific work (according to this).
- MacPorts is an alternative to Homebrew some claim is more compatible with other Linux. However, not all packages are available in MacPorts.
Use Docker
- From Dockerhub account “python” get a Docker image on your machine containing Python3 running within Alpine Linux OS:
- Container:
- Execute the container:
- Use the container
- Stop the Docker instance:
Obsolete Python comes with MacOS
Ever since the Mavericks version of Mac OSX,Python 2 comes installed on MacOS machines.
(Use the index at the right if you want to jump ahead)
- Open a Terminal shell window and issue command:The response, for example:CAUTION: The sub-version of Python that comes installed with MacOS may be obsoleteand needs to be upgraded.But keep to version 2, not version 3 of Python.
- Find where Python2 is installed:The response:You may also see the following if you’ve installed a shim to enable switching of Python versions:
Folders Python on CLI
- List your present working directory:pwdWe next use a Python interactive command to obtain this again.
- Open a Python command-line prompt:pythonThe response shows that version 2 comes with MacOS:The response on a new El Capitan machine:>>> is the Python interpreter prompt.Don’t enter or copy >>> when typing or copying Python commands.
Current Working Directory
- Display Python’s current working directory:>>> import os
>>> os.getcwd()In the response, the “mac” user name is substituted with your user name:The above should be the same as the path obtained from pwd before entering Python. - Futhermore…>>> import os, sys
>>> os.path.dirname(os.path.abspath(sys.argv[0]))The response is your home folder (substitue “mac” with your user name):‘/Users/mac’Exit Python
- Exit the Python interpreter by typing the exit function (with the parentheses symbols) :exit()The exit() commmand works the same for both Python 2 and Python 3.
Using Python 3
- After installing Python3, obtain the Python 3 command line with:python3The response I got:
Python 3 vs. 2
Since 2018, many say “all new Python code should be written for version 3.There are so many new features in Python 3 that it doesn’t make much sense to stick with Python 2 unless you’re working with old code.”
Most new features introduced with Python 3 are not backwards compatible with version 2.
Where are Python executables?
- Python3 is installed in a different folder than Python 2.The response:
- Get the location where Python is installed:which python
which python3- Python v2 is installed in /usr/bin/python
- Python v3 is installed in /usr/local/bin/python3
If you get /Users/user/.pyenv/shims/python3
Python command for Python3
Some prefer to If you want If you tried to commit suicide like the above, the work-around is an alias,which the operating system resolves before going down PATH. - To use Python3 as the default version for the python command, set in you Mac’s ~/.bash_profile
Print is different
For the most part, Python 2 code works with Python 3.
Where Python 2 code fails most often is the print statement.Printing in Python 2 is done like so:
The response:
Hello world!
If you input the above in Python 3, the response is:
SyntaxError: Missing parentheses in call to ‘print’
This is because Python 3 uses a function:
So in Python 2.6+, use the future module to back-port:
Try this:
The response:
Floating point
In Python 2, type in the REPL:
The response is:
In Python3, type:
The response is:
Python programming code
- Download or view a Python program:By convention, Python programming source files have a file suffix of .py regardless of the version.This is because, unlike on Windows, Linux looks at the first line of script files to identify what program is used to run the file.The “shebang” first line in Python 2 programs start with:This is an absolute file system path because the executor doesn’t look on the $PATH for the program defined in ~/.bash_profile.The “shebang” first line in Python 3 programs start with:env is an executable file from virtualenv.
Start a HTTP Server Using Python
A simple HTTP server service can be started with this Python 2 command:
python -m SimpleHTTPServer
For Python3:
python3 -m http.server
The response:
CAUTION: Hitting Ctrl-C on a Mac, does not shutdown the server gracefully, and the binded address will still be in use.
TODO: Add port designation in command line.
File handling using Pathlib
- To create a new folder using Python3: TODO:
- To create a new file using Python3, import the pathlib module’s Path object:
Don’t Uninstall Default Python on macs
The version of Python that comes with Mac OSX should not be removed because some Apple system software have hard-coded references to it.
In this bad advice to harm yourself:
- Elevated privilages (sudo) are necessary to remove Python from your Mac
- Remove symbolic links pointing to the python version:
- Remove references to deleted paths in PATH environment variable within shell profile files.
Depending on which shell you use, any of the following files may have been modified: - List symbolic links pointing to the python version:On El Capitan, this should display: a sym link such as:Or if instead you followed some bad advice and see something like this:
- List symbolic links pointing to the python version:Response:The “././” means that it’s above your HOME folder, in the root of the Mac OS.
- So let’s go there:There are the executables “python” and “python2.7” plus others.
- Run:The response:
- Exit
- Os x sierra dmg not recognized. Run the generic python generically:The response is a newer Python:
- List symbolic links pointing to the Python version:According to this:
Upgrade Python
- Install XCode CLI.
Download Python installer
If you must do it the hard way, bareback, etc:
- In an internet browser at
https://www.python.org/downloads/mac-osx - Click the Latest link at the top or a
specific “Mac OS X 64-bit installer” for macOS 10,9+.File Date Download python-2.7.15-macosx10.9.pkg 2018-05-01 22.7 MB python-2.7.12-macosx10.6.pkg 2016-06-25 21.3 MB python-2.7.11-macosx10.6.pkg 2015-12-05 21.1 MB python-2.7.10-macosx10.6.pkg 2015-05-23 21.1 MB python-2.7.09-macosx10.6.pkg 2014-12-10 21.0 MB python-2.7.08-macosx10.6.pkg 2014-07-02 19.4 MB python-2.7.07-macosx10.6.pkg 2014-05-31 19.4 MB python-2.7.06-macosx10.6.pkg 2013-11-10 19.2 MB This table shows the growth in download size over time,an analysis unique to this page.
Upgrade pip and setuptools
Install pip homebrew without setuptools
Instead of following instructions such as this with:
pip install -U pip setuptools
BTW, on Windows it’s:
python -m pip install -U pip setuptools
- On a Mac use the Mac system package manager Homebrewto install pip (as recommended by this siteand https://pip.readthedocs.io/en/stable/installing):brew install pipConda installs outside the standard structure, so
- Run:brew doctorthis warning appears (which can be safely ignored):
QUESTION: Is there a way to suppress these messages?
Requirements.txt
In a GitHub repo cloned locally,if you see a file Requirements.txt, it is likely a list of Python packages needed by the application:
Notice each specific version is specified.
- In a Terminal shell window, change the directory to where app resides.
- Just for laughs:pip installThe response:The use of the word “requirement” in this message is partly why lists of Python package dependencies are in a requirements.txt file.
Di
- Get a Python 2.7 installed. For example, at:./Cellar/python/2.7.12_2/bin/python2.7
- Verify the sym link:The response:
- Edit ~/.bash_shell to add a shell alias:
- Close and open another Terminal.
- Verify the version.The response should be the newer sub-version:
Virtual Environments
Examples of instructions for installing a requirements.txt file are typically preceded by a
source bin/activate
command which executes the activate script in the project’s bin folder.An activate script is placed in each virtual environment established to store different sets of dependencies required by different projects in separate isolated locaations.
This solves the 'Project X depends on version 1.x but, Project Y needs 4.x' dilemma, and keeps your global site-packages directory clean and manageable.
Before the
pip install
command: Automatically download the packages listed (after you manually change the /path/to)source bin/activate
pip install -r /path/to/requirements.txt
</strong>
pip install -r /path/to/requirements.txt
</strong>
This downloads dependencies from PyPI (the Python Package Index), a public repository of software for the Python programming language at https://pypi.python.org/pypi.
However, adding the “--no-index” option would not use it.
NOTE: pip compiles everything from source if a “wheel” is not available for it. Wheels are a pre-built distribution format that provides faster installation compared to Source Distributions (sdist), especially when a project contains compiled (C language) extensions.
pip install --use-wheel package
### pip scikit-learn #
- In a Terminal on any folder, globally install dependencies libraries:pip install -U scikit-learn
- Edit the Python script to add at the top:
pip iPython Jupyter
- iPython is the kernel of Jupyter.pip install ipython
Virtualenv and Docker
- Don’t pip-install anything beyond virtualenv into its global site-packages.
- Install both virtualenv and system isolation (they are not mutually exclusive):
- Isolate your application server’s OS from its host using Docker/lxc/jails/zones/kvm/VMware/… to one container/vm per application.
- inside of them also do isolate your Python environment using virtualenv from unexpected surprises in the system site-packages.
Remove hassles from managing per-project virtualenvs by using one of these, depending on the shell and operating system used:
- virtualenvwrapper
- virtualenvwrapper-win on MS Windows
PIP (Python Installation Packager)
As of Python 2.7.9 and Python 3.4.x, python.org installers for OS X install pip as wellfrom Activestate.com and download ActivePython. It’s a simple install that gives you both Python and pip.
According to https://www.python.org/download/mac/tcltk/,download fromhttp://www.activestate.com/activetcl/downloadsfile ActiveTcl8.6.3.1.298624-macosx10.5-i386-x86_64-threaded.dmg
After install, the ActiveTcl User Guide is popped up.
Jesse Noller notes inSo you want to use python on the Mac:
“Now, some people may recommend you install Macports or Fink: these are both “sorta” package managers for OS/X, and while I do have Macports installed, I do not use it for Python work. I prefer compilation and self management.”
Easy_install
Others use easy_install (with setuptools) to install packages from the web.
sudo easy_install pip
The response:
Virtual pip environments
The best way to have painless and reproducible deployments is to package whole virtual environments of the application you want to deploy including all dependencies but without configuration.
In the world of Python, an environment is a folder (directory) containing everything that a Python project (application) needs to run in an organised, isolated fashion.
When it is initiated, it automatically comes with its own Python interpreter
- a copy of the one used to create it - alongside its very own pip.
The ability to work with either version 3 or 2.7 on the same machine is neededbecause, as this MacWorld articlepoints out, Mac Mavericks and Yosemite are installed with Python 2.7,cannot run python3 scripts.
You can work on a Python project which requires Django 1.3
while also maintaining a project which requires Django 1.0.
while also maintaining a project which requires Django 1.0.
It’s done by creating isolated Python environments usingvirtualenv (Virtual python environment builder).
sudo pip install virtualenv
As the reponse requests, activate:
source /usr/local/opt/autoenv/activate.sh
This does not issue a response.
- Instead of 'venv', substitute your project name to to create:cd my_project_folder
virtualenv venvExclude the virtual environment folder from source control by adding it to the git ignore list. - List all virtual environments:lsvirtualenv
- To use a particular Python interpreter:virtualenv -p /usr/bin/python2.7 venv
- Activate your project:source venv/bin/activateThe name of the current virtual environment should now appear on the left of the prompt (e.g. (venv)Your-Computer:your_project UserName$).From now on, any package that you install using pip will be placed in the venv folder, isolated from the global Python installation.
autoenv
- To automatically activate an vironment when you cd into it:brew install autoenvThe response:
- Install packages as usual, for example:pip install request
- When you are done working in the virtual environment for the moment:deactivateThe above puts you back to the system’s default Python interpreter with all its installed libraries.
- To delete a virtual environment, delete its folder. In this case, it would be:rm -rf venv
- To keep your environment consistent,
freeze the current state of the environment packages:pip freeze > requirements.txtThis creates (or overwrites) a requirements.txt file containing a simple list of all the packages in the current environment and their respective versions. This file would make it easier to re-create the environment andto install the same packages using the same versions:pip install -r requirements.txtThis ensures consistency across installations, deployments, and developers.
As noted in http://docs.python-guide.org/en/latest/dev/virtualenvs/this create a folder in the current directory containing the Python executable files, and a copy of the pip library which you can use to install other packages. The name of the virtual environment (in this case, it was venv) can be anything;omitting the name will place the files in the current directory instead.
- Open an internet browser to https://www.python.org/downloads/and download file python-3.4.2-macosx10.6.pkg.See http://docs.python-guide.org/en/latest/dev/virtualenvs/https://www.digitalocean.com/community/tutorials/common-python-tools-using-virtualenv-installing-with-pip-and-managing-packages
- To list what packages have been installed:pip list
- Look for packages by keyword:pip search django
Use pip to install Tensorflow
As Siraj shows in his video, on a Mac Terminal,define an environment variable that points to the download URL:
(This is for Python 3 on a Mac.)
Install it using PIP and the variable:
Vagrant
This explanation forks another.
Setup a provider VM solution to store the image (like VMware, AWS, Hyper-V).https://www.virtualbox.org/wiki/Downloadsclick “x86/amd64” next to VirtualBox 4.3.20 for OS X hoststo download VirtualBox-4.3.20.96.dmg (109 MB)Read the 368 page User Manual.
Install https://github.com/dotless-de/vagrant-vbguestto keep VirtualBox guest additions up to date.http://schof.org/2014/03/31/working-around-virtualbox-bug-12879/
![Download Anaconda Mac Download Anaconda Mac](https://thewallpaper.co/wp-content/uploads/2016/10/free-anaconda-wallpaper-windows-mac-wallpapers-artworks-4k-high-definition-free-download-pictures-1600x1200.jpg)
In the Finder, in the Applications folder, drag and drop it onto your Dock for quicker use later.Double-click on VirtualBox for the VirtualBox Manager.
Download the 224.3 MB vagrant_1.7.1.dmg
The binary gets installed in the Applications folder with a link to the /usr/bin so it is added to the shell path.
List commands:
vagrant
vagrant list-commands
vagrant list-commands
Change directory to where you want to store the Vagrant project and run
vagrant init
The response:
A
Vagrantfile
has been placed in this directory. You are nowready to vagrant up
your first virtual environment! Please readthe comments in the Vagrantfile as well as documentation onvagrantup.com
for more information on using Vagrant.ls
This shows Vagrantfile (with capital V).
https://www.vagrantup.com/downloads.html
https://vagrantcloud.com/boxes/searchlists boxes created by the community.
I am pulling the box from ATT M2X https://m2x.att.com/developer/sample-codeThis Repo provides a Vagrant virtual machine that contains several demo applications (Ruby and Python) that report data to AT&T M2X.https://github.com/attm2x/m2x-demo-vagrant
git clone https://github.com/attm2x/m2x-demo-vagrant.git
vagrant box add chef/centos-6.5
bootstrap.bash
User data for Vagrant is filed in the directory from which vagrant was used and is stored in an invisible directory .vagrant.d
Python 2 executables
This advice from 2010.
### Path to executables #
- To see what MacOSwhich pythonIf you have MiniConda installed:If you have Anaconda installed:If you are inside a conda activated environment:
- For a list of what Python executes:ls ~/miniconda2/binThe response begins with this:
Type python
- Find where you are picking up Python from?type pythonIf Python was installed:python is hashed (/usr/bin/python)Alternately, if Conda was installed:python is hashed (/Users/mac/miniconda2/bin/python)
- Open a Terminal shell window and issue command:The response is its version. My Mac Yosemite default of Python shows this:With Miniconda installed on El Capitan, it’s this instead:
- Get the folder:
Download Anaconda Mac Terminal
The response I got is this:
/Users/mac/Library/Python/2.7/lib/python/site-packages
Alternately:
/Users/mac/.local/lib/python2.7/site-packages
Miniconda install
Below is a more “hands-on” description than whatpydata.org andKyle Purdon offers.
- Use an internet browser to visit the Miniconda Download page at http://conda.pydata.org/miniconda.htmlAlternately, download:cd ~/Downloads
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh - Select version to download. For Python 2.7:
Version File Size Python 2.7 Miniconda2-latest-MacOSX-x86_64.sh 20.3 MB Python 3.5 Miniconda3-latest-MacOSX-x86_64.sh 23.4 MB NOTE: Python3 is not backward compatible with Version 2.Notice the “.sh” means these are shell scripts. - Open a Terminal shell window tonavigate to your Downloads folder and run the Python 2.7 script:cd ~/Downloads
bash Miniconda2-latest-MacOSX-x86_64.sh -bPROTIP: The “-b” option specifies unattended with defaults.The response: - Press Enter to accept the license.
- Press “q” to the “:” prompt.
- Type yes.“ERROR: File or directory already exists:”appears if miniconda was already installed.
- Confirm conda version.
Anaconda Install
This video by Corey Schafer explains it well.
- Go to web page:QUESTION: Is there a brew anaconda?
- Click on the operating system icon (Mac, Windows, Linux) or scroll down and press the tab.
- Click to download the “command-line installer”.
- In a (bash) Terminal:The response:
- Press Enter (as if you cared).
- Press Tab until you’re exhausted.
- Type yes and press Enter.Anaconda3 will now be installed into this location:/Users/mac/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
- Press Enter.PREFIX=/Users/mac/anaconda3
- Wait for it to come back to you.
- Type yes.
Conda verson
See https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/
- For the version of conda installed, specify the upper-case V:conda -VAlternately:conda --versionThe response is like:
Update conda
- To update miniconda’s version, use the conda command line installed above:conda update condaThe response is a list of packages to be updated if you agree:
- Press “y” to proceed. A sample response:
- After install, close and then re-open the terminal window so the changes can take effect.
- For a list of packages installed locally (in the currently active environment):conda listThe “py36_1” in the list are pip installed.
.bash_profile config
TODO: Instructions for both Miniconda and conda.
The path to Python should be the first in PATH:
- Open a text editor to ~/.bash_profile and add:export PATH=”~/miniconda2/bin:$PATH”
export PYTHON_PATH=~/miniconda2/bin/pythonWhen you’re done: - Activate the shell file :source ~/.bash_profile
Troubleshoot brew install
- To reset:
Scripting Python versions
TODO: Use a shim so that a script can display the version of Python it is using:
Some answers:
Per https://docs.python.org/3/library/sys.html#sys.hexversion
For a script to ensure that it’s running the version of Python intended:
Alternately:
Conda info
- Get a list:conda infoThe response:
Conda environments
- Get a list of Conda environments (from any folder) using the -e flag:conda info -eAlternately, if you like typing long options:The response are like this:
- Create a Conda environment named py2 using Python 2.7:
- Press y to go ahead.
- Add python packages, such as TensorFlow:
- Activate to use the environment:
- When done using TensorFlow, deactivate the environment:
Conda pyenv
pyenv enables switch between multiple versions of Python on a single system (laptop).
- Create two “named” Conda environments (one with Python2 and the other with Python3):
- Set one of these as my default by adding to my terminal startup file ~/.bash_profile:Typically I only use these “named python” environments to run a Python REPL or do general Python tasks. I’ll create another conda environment named specifically for each real project I work on.
Uninstall
Download Anaconda Python Software
PROTIP: Delete Conda one folder at a time (without the –yes parameter).
anaconda-clean
Files such as:
Install Python packages
From inside a conda environment:
- NumPy at http://www.numpy.orgneeded by http://www.pymvpa.org/installation.htmlpip install numpy
- Instead of downloadinghttp://www.scipy.org/scipylib/download.html#linear algebra, standard distributions, signal processing, data IOpip install scipy
- SKlearnpip install sklearn
- Pandas based onVIDEO: How to install Pandas Miniconda:pip install pandas
- matplotlibOther Python packages:
- xlwings interfaces with Microsoft Excel spreadsheets
- pygame develops GUI
OpenCV for computer vision
Follow the instructions below to install python2 + OpenCV in mac
In case of python3 + OpenCV follow
Conda vs Pip
- Conda handles library dependencies outside of the Python packages as well as Python packages themselves.
- Conda installs from binary, meaning that someone (e.g., Continuum) has already done the hard work of compiling the package, making installation easier, and faster.
- pip can install anything from PyPI in one command.
- Conda requires at least three commands: skeleton, build, install, and possibly more.
- Conda uses its own format, which has some advantages (like being static, and again, Python agnostic).
Conda provides an alternative set of commandspopular for scientific (Machine Learning) computing.See http://conda.pydata.org/docs/_downloads/conda-cheatsheet.pdf
This table lists the difference in commands between Conda and pip, a summary of the more detailed table is at https://conda.io/projects/conda/en/latest/commands.html#conda-vs-pip-vs-virtualenv-commands
Task | Conda package and environment manager command | Pip package manager command | Virtualenv environment manager command |
---|---|---|---|
Install a package | condainstall$PACKAGE_NAME | pipinstall$PACKAGE_NAME | - |
Update a package | condaupdate--name$ENVIRONMENT_NAME$PACKAGE_NAME | pipinstall--upgrade$PACKAGE_NAME | - |
Update package manager | condaupdateconda | Linux/OSX: pipinstall-Upip Win: python-mpipinstall-Upip | - |
Uninstall a package | condaremove--name$ENVIRONMENT_NAME$PACKAGE_NAME | pipuninstall$PACKAGE_NAME | - |
Create an environment | condacreate--name$ENVIRONMENT_NAMEpython | - | cd$ENV_BASE_DIR;virtualenv$ENVIRONMENT_NAME |
Activate an environment | sourceactivate$ENVIRONMENT_NAME | - | source$ENV_BASE_DIR/$ENVIRONMENT_NAME /bin/activate |
Deactivate an environment | sourcedeactivate | - | deactivate |
Search available packages | condasearch$SEARCH_TERM | pipsearch$SEARCH_TERM | - |
Install package from specific source | condainstall--channel$URL$PACKAGE_NAME | pipinstall--index-url$URL$PACKAGE_NAME | - |
List installed packages | condalist--name$ENVIRONMENT_NAME | piplist | - |
Create requirements file | condalist--export | pipfreeze | - |
List all environments | condainfo--envs | - | Install virtualenv wrapper, then lsvirtualenv |
Install other package manager | condainstallpip | pipinstallconda | - |
Install Python | condainstallpython=x.x | - | - |
Update Python | condaupdatepython * | - | - |
PyCharm IDE
https://discussions.udacity.com/t/referencing-pygame-from-pycharm-with-anaconda/223711/13
Turi (Dato) Python algorithms
GraphLab Create from Dato provides scalable “pre-implemented” ML algorithms using Anaconda.Entire courses on its use is at
- https://www.coursera.org/learn/ml-foundations
- https://www.turi.com/learn/userguide/
- https://www.turi.com/products/create/docs/
- https://github.com/learnml/machine-learning-specialization
- https://www.coursera.org/learn/ml-clustering-and-retrieval/supplement/iF7Ji/software-tools-you-ll-need-for-this-course
When the one-year free license is over, notescikit-learn also uses Python with Anaconda.
Python libraries
For matrix operations, use the Numpy open-source Python library for fast performance with data that fits in memory.Quickstart.
In a requirements.txt file:
tweepy (http://www.tweepy.org)
csv (https://pypi.python.org/pypi/csv)
textblob (https://textblob.readthedocs.io/en/dev/)
keras (https://keras.io)
bokehFlaskipythonjupytermatplotlibnosenumpypandasPillowpymcrequestsscikit-imagescikit-learnscipyseabornstatsmodeltensorflowvirtualenvvirtualenvwrapper https://sunever769.weebly.com/review-dr-cleaner-for-mac.html.
OpenCV3
Data Manipulation
SFrame is an open-source, highly-scalable Python library for data manipulation. Unlike Pandas, SFrame is not limited to datasets which can fit in memory, so it can deal with large datasets, even on a laptop.
http://stackoverflow.com/questions/509211/explain-pythons-slice-notation/
Conda
Conda is similar to virtualenv and pyenv, other popular environment managers.
https://virtualenv.pypa.io/en/stable/
https://github.com/yyuu/pyenv
https://www.continuum.io/downloads
conda install numpy pandas matplotlib
conda install jupyter notebook
- List the packages installed, with its version number andwhat version of Python:conda list
Conda Environments
- Create new environment for Python, specifying packages needed:conda create -n my_env python=3 numpy pandas
- Enter an environment on Mac:source activate my_envOn Windows:activate my_envWhen you’re in the environment, the environment’s name appears in the prompt:(my_env) ~ $.
- Leave the environmentsource deactivateOn Windows, it’s just deactivate.
- Get back in again.
- Create an enviornment file by piping the output from an export:conda env export > some_env.yamlWhen sharing your code on GitHub, it’s good practice to make an environment file and include it in the repository. This will make it easier for people to install all the dependencies for your code. I also usually include a pip requirements.txt file using pip freeze (learn more here) for people not using conda.
- Load an environment metadata file:conda env create -f some_env.yaml
- List environments created on your machine:conda env list
- Remove an environment:conda env remove -n some_env
Read:
- https://conda.io/docs/using/index.html
- https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/
Where installed?
When Python is installed using pip, see where it’s installed:
The response on my system:
Miscellaneous
http://stackoverflow.com/questions/990754/how-to-leave-exit-deactivate-a-python-virtualenv?rq=1
https://gist.github.com/alyssaq/f60393545173379e0f3fdescribes install of https://bootstrap.pypa.io/get-pip.py
Download Anaconda Python 2.7 Mac
https://docs.python.org/3/library/2to3.html2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code.
Download Anaconda For Windows 10
References
https://joernhees.de/blog/2014/02/25/scientific-python-on-mac-os-x-10-9-with-homebrew/recommends several pip libraries
https://linuxacademy.com/cp/socialize/index/type/community_post/id/14209released 1/25/2017 by Michael Jenkinsmakes use of AWS Boto3 with Python2 to create S3 buckets, upload files, and delete S3 buckets incode examples as part of Linux Academy’s Red Hat Certified Specialist in Virtualization (EX318) Preparation video Course
More on OSX
Anaconda Python Mac
This is one of a series on Mac OSX:
Please enable JavaScript to view the comments powered by Disqus.