2/11/2024 0 Comments Portauthority macportsIf you are using either of those package managers, you’ll need to locate the Python 2.7 installation directory to be used in the command.Īctivating and deactiving the virtual environmentĪctivate the virtual environment using this “source” command: ~/using-python-venv$. Note: the path will be different with Fink or Homebrew. Save a record of all the current environment variables (so we can see what changes when the virtual environment is activated) using this command: ~/using-python-venv$ env > Ĭreate the virtual environment deployment directory using this command: ~/using-python-venv$ /opt/local/Library/Frameworks/amework/Versions/2.7/bin/virtualenv venv27 This will be whatever is the default on your system. Open a terminal window and create an empty directory somewhere–I called mine “using-python-venv”–and cd into it.Ĭheck the path to the Python binary and the Python version. To check that, let’s create a virtual environment for Python 2.7 from MacPorts. The Python port maintainers at MacPorts are pretty good about upgrades, and so the Python 2.7 installed in the /opt tree is likely to be recent. I don’t use python_select because I find using virtual environments to be a better mechanism. They provide a command you can use to change the default python package to one selected from the various versions you’ve installed via MacPorts. The various python_select packages come along with any MacPorts Python package. I installed each of those using a command like: ~$ sudo port install python27 The following ports are currently installed: Another way to see that is by asking MacPorts to list the Python packages: ~$ port installed python* Usually Apple does not update the system version of Python, and so my system will remain at 2.7.5 (circa 2013) as long as I keep it running Mavericks (also circa 2013).Īs you can tell from the directly listing above, I’ve used MacPorts to independently install Python versions 2.7, 3.3, 3.4, and 3.5. OS X 10.9.5, and that ships with Python 2.7.5. OS X comes with Python already installed. Here are all the Python versions currently installed on my OS X system via MacPorts: ~$ ls /opt/local/Library/Frameworks/amework/Versions/ MacPorts installs all its software under the top level directory /opt. For example, on my OS X system I use the package manager 1 MacPorts to install new versions of Python. Python is, typically, installed side by side on a system at the granularity of major and minor releases. Adding packages to the virtual environment.Virtual environment creation in Python 3.3 and later.Activating and deactiving the virtual environment.First I walk through everything using OS X–i.e., using a Mac–and then, briefly, I describe the same procedures using Windows. In this post I give the details and examples of using the Python virtual environment. In a previous post I gave virtual environments as a solution to the problem of dependency and version collision for software built using languages like Python, Ruby, Node.js, and Go.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |