Osx Python3



Doing it Right¶. Let’s install a real version of Python. Before installing Python, you’ll need to install GCC. GCC can be obtained by downloading Xcode, the smaller Command Line Tools (must have an Apple account) or the even smaller OSX-GCC-Installer package. Note for OSX users. Sudo apt install python3-serial python3-numpy cython3 python3-libxml2 python3-gi python3-dbus python3-psutil python3-cairosvg libpython3-dev.

  1. Osx Python Pip
  2. Install Python3.6 Os X
  3. Osx Update Python3
  4. Linux Python 3.6
  • Python 3 Basic Tutorial
  • Python 3 Advanced Tutorial
  • Python 3 Useful Resources
  • Selected Reading

Python 3 is available for Windows, Mac OS and most of the flavors of Linux operating system. Even though Python 2 is available for many other OSs, Python 3 support either has not been made available for them or has been dropped.

Local Environment Setup

Open a terminal window and type 'python' to find out if it is already installed and which version is installed.

Getting Python

Windows platform

Binaries of latest version of Python 3 (Python 3.5.1) are available on this download page

The following different installation options are available.

  • Windows x86-64 embeddable zip file
  • Windows x86-64 executable installer
  • Windows x86-64 web-based installer
  • Windows x86 embeddable zip file
  • Windows x86 executable installer
  • Windows x86 web-based installer

Note − In order to install Python 3.5.1, minimum OS requirements are Windows 7 with SP1. For versions 3.0 to 3.4.x Windows XP is acceptable.

Linux platform

Different flavors of Linux use different package managers for installation of new packages.

On Ubuntu Linux, Python 3 is installed using the following command from the terminal.

Installation from source

Download Gzipped source tarball from Python's download URL − https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz

Mac OS

Download Mac OS installers from this URL − https://www.python.org/downloads/mac-osx/

  • Mac OS X 64-bit/32-bit installer − python-3.5.1-macosx10.6.pkg
  • Mac OS X 32-bit i386/PPC installer − python-3.5.1-macosx10.5.pkg

Double click this package file and follow the wizard instructions to install.

The most up-to-date and current source code, binaries, documentation, news, etc., is available on the official website of Python −

Python Official Website − https://www.python.org/

You can download Python documentation from the following site. The documentation is available in HTML, PDF and PostScript formats.

Python Documentation Website − www.python.org/doc/

Osx python3 uninstall

Setting up PATH

Programs and other executable files can be in many directories. Hence, the operating systems provide a search path that lists the directories that it searches for executables.

The important features are −

  • The path is stored in an environment variable, which is a named string maintained by the operating system. This variable contains information available to the command shell and other programs.

  • The path variable is named as PATH in Unix or Path in Windows (Unix is case-sensitive; Windows is not).

  • In Mac OS, the installer handles the path details. To invoke the Python interpreter from any particular directory, you must add the Python directory to your path.

Setting Path at Unix/Linux

To add the Python directory to the path for a particular session in Unix −

  • In the csh shell − type setenv PATH '$PATH:/usr/local/bin/python3' and press Enter.

  • In the bash shell (Linux) − type export PYTHONPATH=/usr/local/bin/python3.4 and press Enter.

  • In the sh or ksh shell − type PATH = '$PATH:/usr/local/bin/python3' and press Enter.

Note − /usr/local/bin/python3 is the path of the Python directory.

Setting Path at Windows

To add the Python directory to the path for a particular session in Windows −

  • At the command prompt − type path %path%;C:Python and press Enter.

Note − C:Python is the path of the Python directory

Python Environment Variables

Here are important environment variables, which are recognized by Python −

Sr.No.Variable & Description
1

PYTHONPATH

It has a role similar to PATH. This variable tells the Python interpreter where to locate the module files imported into a program. It should include the Python source library directory and the directories containing Python source code. PYTHONPATH is sometimes preset by the Python installer.

2

PYTHONSTARTUP

It contains the path of an initialization file containing Python source code. It is executed every time you start the interpreter. It is named as .pythonrc.py in Unix and it contains commands that load utilities or modify PYTHONPATH.

3

PYTHONCASEOK

It is used in Windows to instruct Python to find the first case-insensitive match in an import statement. Set this variable to any value to activate it.

4

PYTHONHOME

It is an alternative module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.

Running Python

There are three different ways to start Python −

Interactive Interpreter

You can start Python from Unix, DOS, or any other system that provides you a command-line interpreter or shell window.

Enter python the command line.

Start coding right away in the interactive interpreter.

Here is the list of all the available command line options −

Sr.No.Option & Description
1

-d

provide debug output

2

-O

generate optimized bytecode (resulting in .pyo files)

3

-S

do not run import site to look for Python paths on startup

4

-v

verbose output (detailed trace on import statements)

5

-X

disable class-based built-in exceptions (just use strings); obsolete starting with version 1.6

6

-c cmd

run Python script sent in as cmd string

7

file

run Python script from given file

Script from the Command-line

A Python script can be executed at the command line by invoking the interpreter on your application, as shown in the following example.

Note − Be sure the file permission mode allows execution.

Integrated Development Environment

You can run Python from a Graphical User Interface (GUI) environment as well, if you have a GUI application on your system that supports Python.

  • Unix − IDLE is the very first Unix IDE for Python.

  • WindowsPythonWin is the first Windows interface for Python and is an IDE with a GUI.

  • Macintosh − The Macintosh version of Python along with the IDLE IDE is available from the main website, downloadable as either MacBinary or BinHex'd files.

If you are not able to set up the environment properly, then you can take the help of your system admin. Make sure the Python environment is properly set up and working perfectly fine.

Note − All the examples given in subsequent chapters are executed with Python 3.4.1 version available on Windows 7 and Ubuntu Linux.

We have already set up Python Programming environment online, so that you can execute all the available examples online while you are learning theory. Feel free to modify any example and execute it online.

Most of macOS workstations do not have any NVIDIA graphic boards, hence they cannot run CUDA, for MVS part.So compiling and using Meshroom isnot exactly straightforward.However, Ryan Baumann has compiled his ownHomebrew tap which includesthe necessary formulae, and you can use this post to get an idea of how to usethem to get up and running. Note that this is intended as a first stepfor Mac users wishing to experiment with and improve theAliceVision/Meshroom software, and as a result these instructions maybecome outdated with time.

System Requirements¶

Osx

First off, your Mac will currently need some NVIDIA GPU with a CUDAcompute capability of 2.0 or greater. This is probably a pretty smallportion of all Macs available, but you can check your GPU by looking in“About This Mac” from the Apple icon in the top left corner of thescreen, under “Graphics”. If you have an NVIDIA GPU listed there, youcan check its compute capability on the NVIDIA CUDA GPUspage.

Second, you’re going to need to install the latest CUDAtoolkit. As of thiswriting, that’s CUDA 10.1, which is only officially compatible with OS X10.13 (High Sierra), so you may also need to upgrade to the latestversion of High Sierra (but not Mojave!) if you haven’t already.Alongside this it is aloso suggested to instal the latest NVIDIA CUDA GPUwebdriver, which as of this writing is387.10.10.10.40.118.

Third, CUDA 10.1 is only compatible with the version of ``clang`distributed with Xcode10.1 <https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html>`__,and will refuse to compile against anything else. You may have an olderor newer version of Xcode installed. As of this writing, if you fullyupdate Xcode within a fully updated OS X install, you’ll have Xcode10.1. To get back to Xcode 10.1, what you can do is go to Apple’sDeveloper Downloads page(for which you’ll need a free Apple developer account), then search for“Xcode 10.1”, then install the Command Line Tools for Xcode 10.1 packagefor your OS version. After installing, runsudoxcode-select--switch/Library/Developer/CommandLineTools andthen verify that clang--version showsAppleLLVMversion10.0.0.

Once you’ve done all this, you can verify a working CUDA install bygoing to /Developer/NVIDIA/CUDA-10.1/samples/1_Utilities/deviceQueryand running sudomake&&./deviceQuery, which should output your GPUinformation. If it doesn’t build correctly (i.e. you seenvccfatal:Theversion('??.?')ofthehostcompiler('Appleclang')isnotsupported),or deviceQuery errors or doesn’t list your GPU, you may need to lookover the steps above and check that everything is up to date (you canalso check the CUDA panel in System Preferences).

Osx Python Pip

The following instructions also assume a workingHomebrew install.

macOS Installation¶

If you’ve followed all the above setup instructions and requirements,installing the AliceVision libraries/framework should be as easy as:

Meshroom Installation & Usage¶

This tutorial does not provide a Homebrew formulae for the Meshroom packageitself, as it’s all Pythonand doesn’t seem particularly difficult to install/use once AliceVisionis installed and working correctly. Just follow the install instructionsthere (for my specific Python configuration/installation I used pip3instead of pip and python3 instead of python):

Note

The CUDA-linked AliceVision binaries invoked by Meshroom don’t automatically find the CUDA libraries on the DYLD_LIBRARY_PATH, and setting the DYLD_LIBRARY_PATH from the shell launching Meshroom doesn’t seem to get the variable passed into the shell environment Meshroom uses to spawn commands. Without this, you’ll get an error like:

In order to get around this, you can symlink the CUDA libraries into/usr/local/lib (most of the other workarounds I found forpermanently modifying the DYLD_LIBRARY_PATH seemed more confusing orfragile than this simplerapproach):1

You can undo/uninstall this with:

You may also want to download the voctree dataset:

Then launch with:

Import some photos, click “Start”, wait a while, and hopefully youshould end up with a reconstructed and textured mesh (here’s an exampleof my own which I uploaded to SketchFab). Bydefault, the output will be in MeshroomCache/Texturing/ (relative towhere you saved the project file).

By default, the output will be in MeshroomCache/Texturing/(relative to where you saved the project file).

Install Python3.6 Os X

When you launch Meshroomwithoutsudo, the temp path will be something like this:

When starting with sudo, it will be /tmp/MeshroomCache by default

Footnotes:¶

  1. Previously, I suggested modifying meshroom/core/desc.py so thatthe return value at the end of the ``buildCommandLine`method <https://github.com/alicevision/meshroom/blob/develop/meshroom/core/desc.py#L368>`__instead reads:

    ` <https://ryanfb.github.io/etc/2018/08/17/alicevision_and_meshroom_on_mac_os_x.html#fnref:dyldpath>`__

Originally published on 2018-08-17 by RyanBaumann

Osx Update Python3

This guide was updated on 2019-03-20 to reflect the latest CUDA 10.1 andXcode 10.1 versions. The Homebrew formula was also updated toAliceVision 2.1.0 to support Meshroom 2019.1.0.

Modified for the Meshroom documentation 2019-07-25

Linux Python 3.6

Baumann, Ryan. “AliceVision and Meshroom on Mac OS X.” Ryan Baumann -/etc (blog), 17 Aug 2018,https://ryanfb.github.io/etc/2018/08/17/alicevisionandmeshroomonmacosx.html(accessed 25 Jul 2019).