Второй раз сталкиваюсь с "A Virtual Environment", что это такое и зачем оно ? How to use Python virtualenv?
"...put simply, is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects"
Оказывается, что для сборки Anaconda нужно использовать специальные команды утвновщика Conda
"...put simply, is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects"
Оказывается, что для сборки Anaconda нужно использовать специальные команды утвновщика Conda
Еще лучше идея "виртуального окружения" поясняется в статье "Python Packages and Environments with conda". Ребята из "continuum.io" создали Anaconda именно для того, чтобы снять проблемы соглавования версий и обмена данными между членами научных сообществ. Грузить все в облако Wakari иначе просто нельзя.
Другой важный аспект использования "Virtual Environment" заключается в том, что задачи,которые приходится решать настолько разнообразны, что единое рабочее простанство нельзя раздувать до бесконечности, проще использовать несколько компактных. Anaconda позволяет производить такие настройки.
Первоисточники и ссылки¶
How to use Python virtualenv
Python Packages and Environments with conda
Wakari is a collaborative data analytics platform
Conda documentation
this newer conda blog post
Python Packages and Environments with conda
Wakari is a collaborative data analytics platform
Conda documentation
this newer conda blog post
In [3]:
from IPython.display import HTML, Image
import pattern.web
# We have to determine 'tag1+tag2+tag3' for delicious
# And number of items for parsing from RSS
number=5
tags='anaconda'
url = 'http://delicious.com/v2/rss/altersego2007/' + tags
results = pattern.web.Newsfeed().search(url, count=number)
str=''
for result in results:
str = str + '<br/><a href='+ result.url + ' target="_blank">' + 'ref ' + result.title + '</a> ' + result.text
HTML(str)
Out[3]:
Далее выдержки из "Python Packages and Environments with conda"¶
Having been involved in the python world for so long, we are all aware of pip, easy_install, and virtualenv, but these tools did not meet all of our specific requirements.
The main problem is that they are focused around Python, neglecting non-Python library dependencies, such as HDF5, MKL, LLVM, etc., which do not have a setup.py in their source code and also do not install files into Python’s site-packages directory.
The main problem is that they are focused around Python, neglecting non-Python library dependencies, such as HDF5, MKL, LLVM, etc., which do not have a setup.py in their source code and also do not install files into Python’s site-packages directory.
Under the hood, we have created a concept of environments which are conceptually similar to virtualenvs, but which use filesystem-level hard links to create entirely self-contained Python runtime layouts.
By using the ‘conda’ command line tool, users can easily switch between environments, create environments, and install different versions of libraries and modules into them.
By using the ‘conda’ command line tool, users can easily switch between environments, create environments, and install different versions of libraries and modules into them.
Creating and Using Environments¶
At the core, Anaconda environments are just like directories that contain particular versions of packages. These can be located anywhere, but if they are within the Anaconda installation directory, conda will know about them. Let’s take a look:
In [6]:
!conda info -h
In [7]:
!conda info --envs
In [8]:
!conda info -s
A fresh install, there is just the default environment. Now we’d like to create some new environments.
Maybe we have some existing libraries that perform some interesting analysis, and we’d like to test and compare our library with NumPy 1.6 and also the upcoming NumPy 1.7 release. Let’s see what versions of NumPy are available on our known package channels:
Maybe we have some existing libraries that perform some interesting analysis, and we’d like to test and compare our library with NumPy 1.6 and also the upcoming NumPy 1.7 release. Let’s see what versions of NumPy are available on our known package channels:
In [10]:
!conda search -h
In [11]:
!conda search numpy
We see there are packages for both versions of NumPy. Let’s keep things simple and create environments with the anaconda meta-package (which will install lots of packages in one go), but simply specify the version of NumPy we want in each.
Let’s create an environment with NumPy 1.6 (click on the commands to expand their output):
Let’s create an environment with NumPy 1.6 (click on the commands to expand their output):
In [12]:
!conda create -h
In [*]:
# При запуске из notebook вылетает "Kernel busy"
# запускать надо из консоли
!conda create -n np1.7 anaconda numpy=1.7
In []:
C:\Users\kiss\Documents\IPython Notebooks\web\for_notebook_editing>conda create -n np1.7 anaconda numpy=1
Fetching package metadata: ..
Solving package specifications: ...................................
Package plan for installation in environment C:\Users\kiss\Anaconda\envs\np1.7:
The following packages will be linked:
package | build
---------------------------|-----------------
_license-1.1 | py27_0 hard-link
anaconda-1.8.0 | np17py27_0 hard-link
apptools-4.2.0 | py27_0 hard-link
astropy-0.2.5 | np17py27_0 hard-link
atom-0.3.4 | py27_0 hard-link
beautiful-soup-4.3.1 | py27_0 hard-link
binstar-0.3.1 | py27_1 hard-link
biopython-1.62 | np17py27_0 hard-link
bitarray-0.8.1 | py27_0 hard-link
blaze-0.3 | np17py27_0 hard-link
bokeh-0.2 | np17py27_1 hard-link
boto-2.15.0 | py27_0 hard-link
casuarius-1.1 | py27_0 hard-link
cdecimal-2.3 | py27_1 hard-link
chaco-4.3.0 | np17py27_1 hard-link
colorama-0.2.7 | py27_0 hard-link
configobj-4.7.2 | py27_0 hard-link
cubes-0.10.2 | py27_3 hard-link
cython-0.19.2 | py27_0 hard-link
dateutil-2.1 | py27_2 hard-link
distribute-0.6.45 | py27_0 hard-link
docutils-0.11 | py27_0 hard-link
dynd-python-0.5.0 | np17py27_0 hard-link
enable-4.3.0 | np17py27_0 hard-link
enaml-0.8.3 | py27_0 hard-link
envisage-4.3.0 | py27_0 hard-link
flask-0.10.1 | py27_1 hard-link
gevent-0.13.8 | py27_0 hard-link
gevent-websocket-0.3.6 | py27_2 hard-link
gevent_zeromq-0.2.5 | py27_2 hard-link
greenlet-0.4.1 | py27_0 hard-link
grin-1.2.1 | py27_2 hard-link
h5py-2.2.0 | np17py27_0 hard-link
imaging-1.1.7 | py27_2 hard-link
ipython-1.1.0 | py27_0 hard-link
ipython-notebook-1.1.0 | py27_0 hard-link
ipython-qtconsole-1.1.0 | py27_0 hard-link
itsdangerous-0.23 | py27_0 hard-link
jinja2-2.7.1 | py27_0 hard-link
keyring-3.2 | py27_0 hard-link
launcher-0.1.2 | py27_0 hard-link
libpython-1.0 | py27_0 hard-link
llvmmath-0.1.1 | np17py27_2 hard-link
llvmpy-0.12.0 | py27_0 hard-link
lxml-3.2.3 | py27_0 hard-link
markupsafe-0.18 | py27_0 hard-link
matplotlib-1.3.1 | np17py27_0 hard-link
mayavi-4.3.0 | np17py27_2 hard-link
mdp-3.3 | np17py27_0 hard-link
menuinst-1.0.3 | py27_0 hard-link
meta-0.4.2.dev | py27_0 hard-link
mingw-4.7 | 1 hard-link
networkx-1.8.1 | py27_0 hard-link
nltk-2.0.4 | np17py27_0 hard-link
nose-1.3.0 | py27_1 hard-link
numba-0.11.0 | np17py27_0 hard-link
numexpr-2.2.2 | np17py27_0 hard-link
numpy-1.7.1 | py27_1 hard-link
openpyxl-1.6.2 | py27_0 hard-link
pandas-0.12.0 | np17py27_0 hard-link
patsy-0.2.1 | np17py27_0 hard-link
pep8-1.4.6 | py27_0 hard-link
pip-1.4.1 | py27_0 hard-link
ply-3.4 | py27_0 hard-link
psutil-1.1.2 | py27_0 hard-link
py-1.4.17 | py27_0 hard-link
pycosat-0.6.0 | py27_0 hard-link
pycparser-2.9.1 | py27_0 hard-link
pycrypto-2.6.1 | py27_0 hard-link
pyface-4.3.0 | py27_0 hard-link
pyflakes-0.7.3 | py27_0 hard-link
pygments-1.6 | py27_0 hard-link
pykit-0.1.0 | np17py27_0 hard-link
pyparsing-1.5.6 | py27_0 hard-link
pyreadline-2.0.dev | py27_0 hard-link
pysal-1.6.0 | np17py27_1 hard-link
pyside-1.2.1 | py27_0 hard-link
pytables-3.0.0 | np17py27_1 hard-link
pytest-2.4.2 | py27_0 hard-link
python-2.7.5 | 2 hard-link
pytz-2013b | py27_0 hard-link
pywin32-218.4 | py27_0 hard-link
pyyaml-3.10 | py27_0 hard-link
pyzmq-2.2.0.1 | py27_0 hard-link
requests-1.2.3 | py27_0 hard-link
rope-0.9.4 | py27_0 hard-link
scikit-image-0.9.3 | np17py27_0 hard-link
scikit-learn-0.14.1 | np17py27_0 hard-link
scipy-0.13.0 | np17py27_0 hard-link
six-1.4.1 | py27_0 hard-link
sphinx-1.1.3 | py27_4 hard-link
spyder-2.2.5 | py27_0 hard-link
spyder-app-2.2.5 | py27_0 hard-link
sqlalchemy-0.8.3 | py27_0 hard-link
statsmodels-0.5.0 | np17py27_0 hard-link
sympy-0.7.3 | py27_0 hard-link
tornado-3.1.1 | py27_0 hard-link
traits-4.3.0 | py27_0 hard-link
traitsui-4.3.0 | py27_0 hard-link
vtk-5.10.1 | py27_0 hard-link
werkzeug-0.9.4 | py27_0 hard-link
xlrd-0.9.2 | py27_0 hard-link
xlwt-0.7.5 | py27_0 hard-link
WARNING: the process ipython notebook (11192) is running
WARNING: the process C:\Users\kiss\Anaconda\python.exe C:\Users\kiss\Anaconda\Scripts\ipython-script.py n
WARNING: the process C:\Users\kiss\Anaconda\python.exe -c from IPython.kernel.zmq.kernelapp import main;
ython\profile_default\security\kernel-fec9052d-f6be-4eb6-88d1-a1747e1c0eed.json --IPKernelApp.parent_appn
ofile-dir C:\Users\kiss\.ipython\profile_default --interrupt=1156 --parent=1152 (4264) is running
WARNING: the process C:\Users\kiss\Anaconda\Scripts\conda.bat\..\..\python.exe C:\Users\kiss\Anaconda\Scr
-n np1.7 anaconda numpy=1.7 (2028) is running
WARNING: Continuing installation while the above processes are running is
not recommended. Please, close all Anaconda programs before installing or
updating things with conda.
Continue (yes/no/force) (y/[n]/f)?
Естественно, процесс создания я прервал, а информацию из консоли скопировал сюда. А в перовисточнике автор создает целых два виртуальных окружения и они оражаются в списке по команде:
In [1]:
!conda info -e
To use the python version together with all the packages installed in a given environment, simply run the python executable form that environment. From a bash shell:
In []:
# Linux:
~/anaconda/envs/myenv/bin/python
#windows:
C:\Anaconda\envs\myenv\python.exe
If we’d like to make one of these environments the “default”, we simply need to set our PATH appropriately. From a bash shell:¶
In []:
# Linux:
$ export PATH=~/anaconda/envs/myenv/bin:$PATH
# Windows:
set PATH=C:\Anaconda\envs\myenv\Scripts;%PATH%
Sometimes we don’t want to create environments with all the packages that the anaconda meta-package brings in. Maybe we want to do some testing in a minimal environment, and conda lets us create those, too.
Let’s say we want to create an environment with scikit-learn and its dependencies, but nothing else. First, let’s see what versions of scikit-learn are available:
Let’s say we want to create an environment with scikit-learn and its dependencies, but nothing else. First, let’s see what versions of scikit-learn are available:
In [1]:
!conda search scikit-learn
There are quite a few! By default, conda will install the latest compatible version, so we will just do that. But before we create an environment, let’s take a look at what the dependencies of scikit-learn are:
In [2]:
!conda depends scikit-learn
In [4]:
!conda -h
We don’t need to specify all these dependencies ourselves, we’ll let conda do that work:
In []:
!conda create -n test scikit-learn
Как видно, ко команд уже изменился. Далее в статье речь пошла о создании и подключении собственных репозиториев. Но с предупреждением о том, что материал устарел и надо смотреть новый пост this newer conda blog post
Посты чуть ниже также могут вас заинтересовать
Комментариев нет:
Отправить комментарий