Scipy Import Error with a 'Symbol not found: __gfortran_stop_numeric_f08' - matlab

I am getting an error when trying to import scipy in my Python venv. The full terminal commands/outputs are below. You can see that the scipy package was already installed in another terminal session within this venv. The error appears to be with some gfortran data type and the system looking for it my Matlab directory. I don't know why this would be or how to fix it. I am on a Mac. I tried these same commands on my Linux machine (which also has Matlab installed) and it worked fine. Thanks in advance.
mshafer#Michaels-MacBook-Pro-2 ~ % python3.9 -m venv /Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv
mshafer#Michaels-MacBook-Pro-2 ~ % source /Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/bin/activate
(uavrt_venv) mshafer#Michaels-MacBook-Pro-2 ~ % python3 -m pip install scipy
Requirement already satisfied: scipy in ./Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages (1.9.3)
Requirement already satisfied: numpy<1.26.0,>=1.18.5 in ./Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages (from scipy) (1.23.5)
(uavrt_venv) mshafer#Michaels-MacBook-Pro-2 ~ % python3
Python 3.9.15 (main, Oct 11 2022, 22:27:25)
[Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy import interpolate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/__init__.py", line 211, in __getattr__
return _importlib.import_module(f'scipy.{name}')
File "/usr/local/Cellar/python#3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/interpolate/__init__.py", line 166, in <module>
from ._interpolate import *
File "/Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/interpolate/_interpolate.py", line 11, in <module>
import scipy.special as spec
File "/Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/special/__init__.py", line 649, in <module>
from . import _ufuncs
ImportError: dlopen(/Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/special/_ufuncs.cpython-39-darwin.so, 0x0002): Symbol not found: __gfortran_stop_numeric_f08
Referenced from: /Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/special/_ufuncs.cpython-39-darwin.so
Expected in: /Applications/MATLAB_R2022a.app/sys/os/maci64/libgfortran.3.dylib

This error is arising because an incorrect libgfortran is being loaded. scipy is distributed with a vendored version of libgfortran. However, for some reason a libgfortran sited in a Matlab directory is being loaded. These kinds of problems can be got to the bottom of, but it can be complicated as there are various ways that shared libraries can be loaded, and the user can change how that occurs as well.
What is the output of otool -L /Users/mshafer/Desktop/PLAYGROUND/CODE_TOEPLITZ/uavrt_venv/lib/python3.9/site-packages/scipy/special/_ufuncs.cpython-39-darwin.so?
I would expect this to be something like:
scipy/special/_ufuncs.cpython-310-darwin.so:
#loader_path/../.dylibs/libopenblasp-r0.3.20.dylib (compatibility version 0.0.0, current version 0.0.0)
#loader_path/../.dylibs/libgfortran.5.dylib (compatibility version 6.0.0, current version 6.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
This means that the dlopen call should go up a directory, down into .dylibs (which is where the vendored libraries are placed), then load libgfortran from there.
Have you set the LD_LIBRARY_PATH variable?
How was Python installed?

Related

vtkCommonCorePython missing error in python3-paraview on Ubuntu 20

I'm trying to use paraview scripting within python3 for Ubuntu 20.04.1 LTS. If I open python3 on the command line I get the error
$> python3
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/paraview/simple.py", line 41, in <module>
from paraview import servermanager
File "/usr/lib/python3/dist-packages/paraview/servermanager.py", line 56, in <module>
from paraview.modules.vtkPVServerImplementationCore import *
File "/usr/lib/python3/dist-packages/paraview/modules/vtkPVServerImplementationCore.py", line 2, in <module>
from . import vtkPVClientServerCoreCore
File "/usr/lib/python3/dist-packages/paraview/modules/vtkPVClientServerCoreCore.py", line 2, in <module>
from . import vtkPVCore
File "/usr/lib/python3/dist-packages/paraview/modules/vtkPVCore.py", line 2, in <module>
from . import vtkClientServer
File "/usr/lib/python3/dist-packages/paraview/modules/vtkClientServer.py", line 3, in <module>
from .vtkClientServerPython import *
ImportError: Failed to load vtkClientServerPython: No module named vtkmodules.vtkCommonCorePython
>>>
I have python3-paraview, paraview, paraview-dev, vtk7, python3-vtk7, etc installed from the synaptic installation manager. There are two files with vtkCommonCorePython inside the dist-packages directory :
/usr/lib/python3/dist-packages/vtk/vtkCommonCorePython.cpython-38-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/vtkmodules/vtkCommonCorePython.cpython-38-x86_64-linux-gnu.so
Searching the internet shows that other people have had similar problems, and solved it but including the paths to vtkCommonCorePython, but sys.path does include /usr/lib/python3/dist-packages, so vtkCommonCorePython should be found.
Can anybody see what might be missing in this case?
Many thanks! John
There are (or at least there were in previous versions) some slightly tricky conflicts between the vtk and paraview packages in python. I've found it's best to keep paraview for python in its own conda environment.
Assuming you have conda already, you should be able to get up and running with:
conda create -n paraview -c conda-forge paraview

How can I import libraries in PythonAnywhere and use them in a Python notebook?

I'm both updating and installing packages/libaries, but are only able to use them through the Python3.6 console.
10:40 ~ $ pip3.6 install -U --user scikit-learn
Requirement already up-to-date: scikit-learn in ./.local/lib/python3.6/site-packages
Requirement already up-to-date: numpy>=1.11.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: joblib>=0.11 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: scipy>=0.17.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
When using pip install it fails with :
10:40 ~ $ pip install -U --user scikit-learn
Collecting scikit-learn
Using cached https://files.pythonhosted.org/packages/18/28/5a48b00599b476875415b97bdfdb3849bafb31183c1d785501dbc8a77aa2/scikit-learn-0.22.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-JYw8w1/scikit-learn/setup.py", line 47, in <module>
import sklearn
File "sklearn/__init__.py", line 81, in <module>
from . import __check_build # noqa: F401
File "sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named _check_build
___________________________________________________________________________
Contents of sklearn/__check_build:
__init__.py _check_build.pyx __init__.pyc
setup.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
It appears that you are importing a local scikit-learn source tree. For
this, you need to have an inplace install. Maybe you are in the source
directory and you need to try from another location.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JYw8w1/scikit-learn/
If you've installed a package using pip3.6, make sure that your kernel version for your notebook is 3.6 -- if it's (say) 3.7, then it won't work, because each version of Python has its own separate set of installed modules.
I imported the notebook, and forgot to change Kernel Python3.6. It was still on Python3. Changed notebook to 3.6, and the it used the updated libary's-
When you run pip on PythonAnywhere, outside virtual environment, it installs packages for python2. The latest version of scikit-learn to work with python2 is 0.20.4. So, install it with pip install scikit-learn==0.20.4
You tried to install 0.22.1 with python2.

Spyder fails on Anaconda 2-4.3.21/2-4.4.0 - ImportError: No module named > shutil_get_terminal_size

From the Anaconda command prompt I launch Spyder. Spyder launches, even loading and issuing a warning that my previous session crashed and that I should consider resetting (which I eventually did without result). The process carries on and then hangs on forever, failing to start (i.e. open the working windows with code, console, variables etc.)
Tried to reset Spyder
Spyder --reset
Spyder resets properly but still fails to start
Spyder Version: 3.1.4
Python Version: 2.7.13
Anaconda Version: 4.3.21
Qt Version: 5.6.2
PyQt Version: 5.6.0
Operating system: Windows 10
Then I uninstalled and reinstalled Anaconda this time Version: 2.4.4.0. Spyder launched once satisfactorily only to crash ever after.
Investigating the process further, it cought up the following error:
spyder --show-console
(C:\Users\me\Anaconda2) C:\Users\me>spyder --show-console Traceback
(most recent call last): File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\app\mainwindow.py",
line 3011, in main mainwindow = run_spyder(app, options, args) File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\app\mainwindow.py",
line 2913, in run_spyder main.setup() File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\app\mainwindow.py",
line 873, in setup from spyder.plugins.ipythonconsole import
IPythonConsole File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\plugins\ipythonconsole.py",
line 60, in from spyder.widgets.ipythonconsole import ClientWidget
File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\widgets\ipythonconsole_init_.py",
line 12, in from .debugging import DebuggingWidget File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\widgets\ipythonconsole\debugging.py",
line 16, in from qtconsole.rich_jupyter_widget import
RichJupyterWidget File
"C:\Users\me\Anaconda2\lib\site-packages\qtconsole\rich_jupyter_widget.py",
line 14, in from .jupyter_widget import JupyterWidget File
"C:\Users\me\Anaconda2\lib\site-packages\qtconsole\jupyter_widget.py",
line 19, in from IPython.lib.lexers import IPythonLexer,
IPython3Lexer File
"C:\Users\me\Anaconda2\lib\site-packages\IPython_init_.py", line 48,
in from .core.application import Application File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\core\application.py",
line 25, in from IPython.core import release, crashhandler File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\core\crashhandler.py",
line 28, in from IPython.core import ultratb File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\core\ultratb.py",
line 128, in from IPython.utils.terminal import get_terminal_size
File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\utils\terminal.py",
line 22, in from backports.shutil_get_terminal_size import
get_terminal_size as _get_terminal_size ImportError: No module named
shutil_get_terminal_size
(C:\Users\me\Anaconda2) C:\Users\me>
So then I tried the following:
(C:\Users\me\Anaconda2) C:\Users\me>conda install
shutil_get_terminal_size Fetching package metadata ...........
PackageNotFoundError: Package missing in current win-64 channels:
shutil_get_terminal_size Close matches found; did you mean one of
these?
shutil_get_terminal_size: get_terminal_size
Btw Spyder issue or Anaconda issue?
So anway I proceeded to install get_terminal_size and have a go at it
(C:\Users\me\Anaconda2) C:\Users\me>conda install get_terminal_size
Fetching package metadata ........... Solving package specifications:
.
All requested packages already installed.
packages in environment at C:\Users\me\Anaconda2:
get_terminal_size 1.0.0 py27_0
Then tries again to launch in the command prompt
spyder
which fails including trying once again after resetting
spyder --reset
Investigating further
spyder --show-console
results in me returning straight back to square one
(C:\Users\me\Anaconda2) C:\Users\me>spyder --show console Traceback
(most recent call last): File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\app\mainwindow.py",
line 3011, in main mainwindow = run_spyder(app, options, args) File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\app\mainwindow.py",
line 2913, in run_spyder main.setup() File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\app\mainwindow.py",
line 873, in setup from spyder.plugins.ipythonconsole import
IPythonConsole File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\plugins\ipythonconsole.py",
line 60, in from spyder.widgets.ipythonconsole import ClientWidget
File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\widgets\ipythonconsole_init_.py",
line 12, in from .debugging import DebuggingWidget File
"C:\Users\me\Anaconda2\lib\site-packages\spyder\widgets\ipythonconsole\debugging.py",
line 16, in from qtconsole.rich_jupyter_widget import
RichJupyterWidget File
"C:\Users\me\Anaconda2\lib\site-packages\qtconsole\rich_jupyter_widget.py",
line 14, in from .jupyter_widget import JupyterWidget File
"C:\Users\me\Anaconda2\lib\site-packages\qtconsole\jupyter_widget.py",
line 19, in from IPython.lib.lexers import IPythonLexer,
IPython3Lexer File
"C:\Users\me\Anaconda2\lib\site-packages\IPython_init_.py", line 48,
in from .core.application import Application File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\core\application.py",
line 25, in from IPython.core import release, crashhandler File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\core\crashhandler.py",
line 28, in from IPython.core import ultratb File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\core\ultratb.py",
line 128, in from IPython.utils.terminal import get_terminal_size
File
"C:\Users\me\Anaconda2\lib\site-packages\IPython\utils\terminal.py",
line 22, in from backports.shutil_get_terminal_size import
get_terminal_size as _get_terminal_size ImportError: No module named
shutil_get_terminal_size
PS: I have used with satisfaction Anaconda and Spyder for months now without any issue, cannot understand what's wrong.
Actually I found a solution which was to conda reinstall ipython and pip reinstall backports.shutil_get_terminal_size :
conda uninstall ipython
conda install python
pip uninstall backports.shutil_get_terminal_size
pip install backports.shutil_get_terminal_size
For more info I suggest to consult the following issues:
ipython/ipython/#9656
ipython/ipython/#9815 (I cannot post more than 2 links so google it up!)
chrippa/backports.shutil_get_terminal_size/#9
For some reason however Spyder then issues a warning that nbconvert isn't installed whereas both conda and pip install nbconvert show that nbconvert is fully installed and up to date...
Spyder dependancy missing nbconvert >=4.0: None (NOK) Please install
to prevent this message displaying Fetching package metadata
........... Solving package specifications: .
conda install nbconvert
All requested packages already installed. packages in environment at
C:\Users\me\Anaconda2:
nbconvert 5.2.1 py27_0
pip install nbconvert
Requirement already satisfied: nbconvert in c:\users\me\anaconda2\lib\site-packages Requirement already satisfied: mistune!=0.6 in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: jinja2 in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: pygments in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: traitlets>=4.2 in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: jupyter_core in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: nbformat in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: entrypoints>=0.2.2 in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: bleach in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: testpath in c:\users\me\anaconda2\lib\site-packages (from nbconvert)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\me\anaconda2\lib\site-packages (from jinja2->nbconvert)
Requirement already satisfied: six in c:\users\me\anaconda2\lib\site-packages (from bleach->nbconvert)
Requirement already satisfied: html5lib!=0.9999,!=0.99999,<0.99999999,>=0.999 in c:\users\me\anaconda2\lib\site-packages (from bleach->nbconvert)

Geodjango Exception when importing django.contrib.gis.gdal: OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name

I have followed the tutorial for installing Geodjango on my Ubuntu 14.04. I am using Django 1.10 and Python 3.5, postgres-9.6 and postgis 2.3.
I have checked here and here, but found no solution.
In a newly installed ubuntu 14.04 Virtual Machine, it worked.
But in my installation, when I tried making migrations, I got:
OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
Investigating a bit further, I tried simply:
from django.contrib.gis import gdal
And got:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/__init__.py", line 49, in <module>
from django.contrib.gis.gdal.driver import Driver # NOQA
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/libgdal.py", line 48, in <module>
lgdal = CDLL(lib_path)
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
Is there any suggestions on how I could repair my setup?
UPDATE
It seems to be a problema with my conda environment. When I started using a pip virtualenv, the problem did not arise anymore. I am not answering the question, because I could not find the solution, only a workaround. But rebuilding the environment with pip virtualenv works.
In conda environment: conda install -c conda-forge gdal=2.2.1
In django settings.py:
GDAL_LIBRARY_PATH = '<HOME>/anaconda3/envs/<env_name>/lib/libgdal.so'
I was having this issue as well and the specifying
GDAL_LIBRARY_PATH = <HOME>/anaconda3/envs/<env_name>/lib/libgdal.so
(in project.settings or os.environ.setdefault) led to
libicui18n.so.56: cannot open shared object file: No such file or directory.
The fix that worked for me was to upgrade icu:
conda install -c conda-forge icu=58
Upgrading icu lead to some changes in other package versions as well (qt downgraded from 5.6.2-4 to 5.6.2-3, the rest upgraded).
I simply run under my conda environment:
conda install gdal
Guy de Carufel's solution did not work for me, though he pointed to a correct direction, thanks
Have you built SQLite from source? Then, you forgot to enable Column metadata. Recompile SQLite with
CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" ./configure
make
sudo make install
Have fun using the cutting edge SQLite.
Reference - https://www.sqlite.org/compile.html#enable_column_metadata

Virtualenv causing setuptools error

I am having trouble running a virtualenv, and I keep getting this same error code: "setuptools pip wheel failed with error code 1"
I saw some pages talking about how this is a discrepancy between different versions of setuptools, but I've uninstalled and reinstalled virtualenv and setuptools in several versions to no results. Does anyone know what's happening here?
Roberts-MacBook-Air:script Rob$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/Users/Rob/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/Users/Rob/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/Rob/anaconda/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
Roberts-MacBook-Air:script Rob$
I would say that Anaconda causes the conflict, though to be more specific, it appears as if Anaconda's virtualenv is the problem. Running which virtualenv on my macbook (where I'm having the same problem) yields /Users/me/anaconda/bin/virtualenv while running it on the linux system I just tested this on yields /usr/local/bin/virtualenv.
So, on OS X, I downloaded virtualenv using /usr/local/bin/pip install virtualenv. This doesn't create a virtualenv binary (or it didn't for me) in the PATH folders, so I had to type this painfully long command:
sudo /usr/local/bin/python ... {the path to virtualenv.py in the system python's site-packages folder} new_env
And that did it. But that's ridiculous. No one wants to do that - even creating links would still be hacking it when you don't need to.
According to the ContinuumIO github page on this very subject, the virtualenv env and source /bin/activate commands are replaced with conda create -n env python=2.7 and source activate env.
Tested on my macbook (running Anaconda2 v4 on OS Yosemite) and it worked out.