Installing virtualenvwrapper on mac osx 10.7.3 - python

Let me start by saying I'm new at programming, mac osx, and bash.
I'm having a tough time getting virtualenvwrapper setup on my Mac osx 10.7.3.
Its most certainly a path settings issue but I'm just having trouble getting it working.
Setup of virtualenvwrapper in .bashrc
export WORKON_HOME=$HOME/.Apps
source /usr/local/bin/virtualenvwrapper.sh
Some terminal output:
which easy_install
/usr/bin/easy_install
python -V
Python 2.7.1
When I run "source .bashrc" in the terminal I get no output.
When I run mkvirtualenv in the terminal I get:
Error [Errno 2] No such file or directory while executing command install_name_tool -change /System/Library/Fram.../Versions/2.7/Python #executable_path/../.Python 1/bin/python
Could not call install_name_tool -- you must have Apple's development tools installed
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.7.1.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 928, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 1029, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.7/site-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 1347, in install_python
py_executable])
File "/Library/Python/2.7/site-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 966, in call_subprocess
cwd=cwd, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
OSError: [Errno 2] No such file or directory

You probably just need to install XCode. It should be a free (if large) download/install from the App Store.
For future reference, I highly recommend using a package manager and pip (instead of easy_install) for python development on OS X. My preferred package manager is Homebrew, but MacPorts and Fink are also good. Among other things, pip lets you uninstall stuff, which easy_install cannot simply do.

Related

error with installing virtualenv with python 3

ive updated to python3 and downloaded virtualenv using:
sudo /usr/bin/easy_install virtualenv
when i go to start the virtualenv i got the following error message :
virtualenv project1
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 6, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'zipp>=0.4' distribution was not found and is required by importlib-resources
i looked around and realised the that 'zipp' had not been installed so i installed that also. when i went to run the virtualenv again i got the same error message again as above. and for some reason it keeps referencing python 2.7 even though ive upgraded to python3.
please try this ..
you just follow Exactly the bellow Items :
Open your Command Prompt AS ADMINISTRATOR -> right click on CMD and RUN AS ADMINISTRATOR
go to which Folder to you want to create your VirtualENV : For example : > Cd C:\Users...\Documents\python\src
type it : PIP install Virtualenv
make sure your internet connection is Ok
4.type : python -m venv env
and then you can create your project inside this env folder..
all Comment code should be write in Command Prompt AS Administrator
i ended up using the built in python 3 venv package. it works just as well and it was straight forward and simple. thank you for all the help
start the virtual environment: python3 -m venv project1
activate the virtual environment: source project1/bin/activate
deactivate the virtual environment: deactivate
If you're using Python 3.3 or later, you can use the built-in venv [https://docs.python.org/3/library/venv.html] module. This will reduce the number of dependencies, making installation and troubleshooting a bit easier.
To double-check that you are invoking the correct Python interpreter, run python3 -V or python -V (depending on how it's aliased).
Just try out.
virtualenv venv
It should create a venv directory in same directory if python 3.x is being used.

Virtualenv venv fails with the following error

I'm new to Python development and I'm trying to instal virtualenv in my project directory.
However I have the following error:
Installing collected packages: pip, setuptools
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_set.py", line 549, in install
**kwargs
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_install.py", line 754, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_install.py", line 963, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/wheel.py", line 234, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/wheel.py", line 212, in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 82, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip/__init__.py'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 993, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 961, in install_wheel
'PIP_NO_INDEX': '1'
File "/Library/Python/2.7/site-packages/virtualenv.py", line 903, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/alexandrurada...oard/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 2
I installed pip with
easy_install pip
Then I installed virtualenv with
pip install virtualenv
Without any errors. However I'm still getting this. I didn't want to try it with sudo. Should I?
UPDATE: I installed them with sudo, and I got rid of this error. However another one when trying to install something with pip:
air:dashboard alexandrurada$ pip install flask
-bash: /usr/local/bin/pip: "path_here": bad interpreter: No such file or directory
UPDATE 2: The earlier error was because of a space inside a directory name. Looks like path doesn't work with such names.
Anyway, the error I'm getting now is
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named pip
I checked my /usr/local/bin/pip and the file exists.
You need sudo pip install virtualenv to install virtualenv globally. When setting up your virtualenvs make sure you don't use sudo and that you activate your virtualenv before trying to install.
[Errno 13] Permission denied: means you don't have write permissions.
Install a newer version of pip and avoid using easy_install.
Download pip from: https://bootstrap.pypa.io/get-pip.py
and then run Python on it:
$ python get-pip.py
If you want to install pip to the global path, you likely want to run that last command with sudo. Without using sudo, pip will get installed for use with whatever Python interpreter is in your path.
From here, you can install virtualenv with pip:
$ pip install virtualenv
From your responses, it seems like you'd be best served by getting your system in a known state: Download that file, then run sudo python get-pip.py so you're running with a known-working pip install.

Python Pip Install "Egg" Error (Pandas and other modules)

Having issues installing some python modules (for example pandas) and also had some issues installing ipython notebook.
This error seems to have come up before for other folks (Python pip install fails: invalid command egg_info), but they were using Python 2.7, whereas I'm using 2.6 (default with my Mac OS 10.6). Also I tried easy_install -U setuptools and pip install --upgrade setuptools but neither worked.
This is the error I get for installing pandas:
Command python setup.py egg_info failed with error code 1 in /private/var/folders/Wm/WmmbYincEnuCrAMtGBudAk+++TM/-Tmp-/pip_build_AWal/pandas
Storing debug log for failure in /Users/AWal/Library/Logs/pip.log
For installing iPython, this is the error that I get:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/wheel.py", line 341, in move_wheel_files
generated.extend(maker.make_multiple(['%s = %s' % kv for kv in console.items()]))
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 316, in make_multiple
filenames.extend(self.make(specification, options))
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 305, in make
self._make_script(entry, filenames, options=options)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 209, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 189, in _write_script
self._fileop.write_binary_file(outname, script_bytes)
File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/util.py", line 384, in write_binary_file
with open(path, 'wb') as f:
IOError: [Errno 13] Permission denied: '/usr/local/bin/sphinx-apidoc'
Storing debug log for failure in /Users/AWal/Library/Logs/pip.log
Any thoughts on what to do?
UPDATE:
When I do sudo pip install pandas (another module that I can't install), I get a long long traceback with the end error message:
RuntimeError: Broken toolchain: cannot link a simple C program
And traceback (a sample of it of the 100 or so lines) looks like this:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/private/tmp/pip_build_root/pandas/setup.py", line 619, in <module>
**setuptools_kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py", line 113, in setup
File "build/bdist.macosx-10.6-universal/egg/setuptools/dist.py", line 266, in __init__
File "build/bdist.macosx-10.6-universal/egg/setuptools/dist.py", line 312, in fetch_build_eggs
File "build/bdist.macosx-10.6-universal/egg/pkg_resources/__init__.py", line 753, in resolve
File "build/bdist.macosx-10.6-universal/egg/pkg_resources/__init__.py", line 1005, in best_match
File "build/bdist.macosx-10.6-universal/egg/pkg_resources/__init__.py", line 1017, in obtain
File "build/bdist.macosx-10.6-universal/egg/setuptools/dist.py", line 379, in fetch_build_egg
File "build/bdist.macosx-10.6-universal/egg/setuptools/command/easy_install.py", line 619, in easy_install
A permission Denied message would suggest you to run your command as root as suggested by Hackaholic.
try sudo pip install YOUR_PACKAGE
You might also want to have a look at virtualenv to use a more isolated environment.
Under debian based distributions, you might install python-virtualenv package with apt-get install python-virtualenv.
Then create a virtual environment names whatever by typing virtualenv whatever (this will create a folder whatever inside your current folder.
Then cd to it and type bin/activate to enter this virtual environment.
From there try again your pip install command.
Might help
UPDATE :
You might try to use the suggested solutions available here
To sumup, try to add export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future inside ~/.bash_profile
This question comes first in Google, but the second one actually worked:
pip install -U setuptools
pip install ez_setup

Virtualenv returning a 'No such file or directory...' error

The command virtualenv --no-site-packages env/ produces the following error stack trace:
The --no-site-packages flag is deprecated; it is now the default behavior.
New python executable in env/bin/python
Installing setuptools.............done.
Installing pip...
Error [Errno 2] No such file or directory while executing command /home/zach/School/CS...env/bin/easy_install /usr/local/lib/pytho...pport/pip-1.1.tar.gz
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.7.1.2', 'console_scripts', 'virtualenv')()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 928, in main
never_download=options.never_download)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1042, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 640, in install_pip
filter_stdout=_filter_setup)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 966, in call_subprocess
cwd=cwd, env=env)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1239, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I am using Ubuntu 11.10 and Python 2.7.
EDIT:
Figured it out.
I originally installed it with pip, so I uninstalled via pip and that reinstalled via apt-get.
I had the same on debian. Upgrade python-virtualenv resolves the problem.
apt-get upgrade python-virtualenv
virtualenv looks to be trying to install pip using easy_install from a local archive. Can you verify that it exists at /usr/local/lib/pytho...pport/pip-1.1.tar.gz ?
You may want to ensure that you have pip properly install beforehand. Try: easy_install -U pip first.
In mac run pip install virtualenv virtualenvwrapper to install virtualenv.
You should make sure the path to easy_install does not have spaces in it: /home/zach/School/CS...env/bin/easy_install
If you are Debian user, then this command should resolve the problem:
sudo apt-get upgrade python-virtualenv

Unable to do heroku's Python tutorial within Dropbox folder

EDIT2: OK this is weird. (I can't answer my own question, so I just put it as another edit to the question. I think it has something to do with the fact that I tried to do this installation within a Dropbox-synced directory. I got this to work on my Desktop. Can anyone explain why this is the case?
Original question:
I'm trying to do Heroku's Python setup tutorial (http://devcenter.heroku.com/articles/python), on my Mac OS X (Lion), but I get caught up with the step of creating a virtualenv.
So what I did was this in the command line (not using sudo caused permissions error):
sudo pip install virtualenv
But then, when I do "virtualenv venv --distribute" (I also tried with sudo), I get the following error:
New python executable in venv/bin/python
Installing distribute..............................................................................................................................................................................................................................................................................................done.
Installing pip...
Error [Errno 2] No such file or directory while executing command /Users/AndyFang/Drop...env/bin/easy_install /Library/Python/2.7/...pport/pip-1.1.tar.gz
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.7.1.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 928, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1042, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 640, in install_pip
filter_stdout=_filter_setup)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 966, in call_subprocess
cwd=cwd, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Not really sure what to do. It seemed like I didn't have easy_install on my Mac, but I do have it... I'm not sure what the deal is?
EDIT: I also just tried installing virtualenv with easy_install, but I get the exact same error.
If your problem is the same as mine, then it's because there's a space somewhere in the path to your Dropbox-synced folder.
Virtualenvs aren't portable, so you can't keep them synced across multiple machines if the paths don't match up.
In general, it's a bad idea :)

Categories