Virtualenv command not found after installation using MacPorts

I have python 2.7 installed via mac ports on mac. I installed virtualenv via macports (py27-virtualenv @ 1.6.1_0 (active). When I issue the command: virtualenv demo_venv --no-site-packages, I get this error: - bash: virtualenv: command not found. Choosing virtualenv up @all so i need to symbolically bind it to my python27 location?

+6
source share
5 answers

You need to make sure virtualenv is in your PATH, although it should be if it was installed correctly.

+1
source

As you noted, MacPorts offers several versions of pyXX-virtualenv packages. You must tell MacPorts which of these versions you want to use by default:

 port select --list virtualenv port select --set virtualenv virtualenv27 which virtualenv 

After that, you can simply type virtualenv (assuming that the MacPorts bin directory is in your path).

+35
source

virtualenv-2.7 command, not just virtualenv .

If you look at the contents of the package, you will see that an executable file called virtualenv not installed.

+4
source

MacPorts installs versions with the virtualenv version in /opt/local/bin , the default location for MacPorts. When using MacPorts, you need to make sure that /opt/local/bin is in the shell PATH environment variable. Here I show that both py26-virtualenv and py27-virtualenv :

 $ echo $PATH /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Developer/Tools $ ls -l /opt/local/bin/virtuale* lrwxr-x--- 1 root admin 13 Oct 15 2009 /opt/local/bin/ virtualenv@ -> virtualenv2.6 lrwxr-xr-x 1 root wheel 74 May 17 02:20 /opt/local/bin/ virtualenv-2.6@ -> /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenv lrwxr-xr-x 1 root wheel 74 May 17 02:29 /opt/local/bin/ virtualenv-2.7@ -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenv lrwxr-xr-x 1 root wheel 88 Jun 27 2010 /opt/local/bin/ virtualenvwrapper_bashrc-2.6@ -> /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvw 

In general, if you want to know what files the MacPort port installs, and where, port contents you can find out:

 $ port contents py27-virtualenv Port py27-virtualenv contains: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenv /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv-1.6.1-py2.7.egg-info/PKG-INFO /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv-1.6.1-py2.7.egg-info/SOURCES.txt /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv-1.6.1-py2.7.egg-info/dependency_links.txt /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv-1.6.1-py2.7.egg-info/entry_points.txt /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv-1.6.1-py2.7.egg-info/not-zip-safe /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv-1.6.1-py2.7.egg-info/top_level.txt /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.pyc /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv_support/__init__.py /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv_support/__init__.pyc /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv_support/distribute-0.6.16.tar.gz /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv_support/pip-1.0.1.tar.gz /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg /opt/local/bin/virtualenv-2.7 /opt/local/share/doc/py27-virtualenv/index.txt /opt/local/share/doc/py27-virtualenv/news.txt 
+3
source

If you are using virtualenvwrapper, you can configure the shell environment to point to the correct virtualenv script. Install the py27-virtualenvwrapper port and add these lines to your Bash profile:

 export VIRTUALENVWRAPPER_VIRTUALENV=/opt/local/bin/virtualenv-2.7 source /opt/local/bin/virtualenvwrapper.sh-2.7 

When using virtualenvwrapper commands, no other hackers or symbolic links are required:

 % mkvirtualenv demo_venv --no-site-packages 
+2
source

Source: https://habr.com/ru/post/892287/


All Articles