I have setup zsh on iterm in mac. While trying to set up virtualenvwrapper for using virtualenv in python projects I ran into the following error:
--
Was trying to figure out why this was happening and finally found that the issue is something to do with LANG settings with zsh.
The solution was pretty simple though:
I just added the following lines in ~/.zshrc
and ran
After which I re-ran
and it worked.
But later while creating virtualenv I faced a different issue:
Add following line to ~/.zshrc
The above does not work. And I don't know the exact reason.
But it has something to do with symlinking to the system level python env that is not the same as symlinking to anaconda env.
To resolve the above issue you can specify the python version to be used in the virtualenv
--
Happy :)
➜ pip install virtualenvwrapper
Collecting virtualenvwrapper
Using cached virtualenvwrapper-4.7.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 156, in save_modules
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 246, in run_setup
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 276, in run
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 245, in runner
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 47, in _execfile
File "/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/easy_install-ff5qsxzn/pbr-1.10.0/setup.py", line 22, in <module>
File "/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/easy_install-ff5qsxzn/pbr-1.10.0/pbr/util.py", line 264, in cfg_to_args
File "/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/easy_install-ff5qsxzn/pbr-1.10.0/pbr/util.py", line 566, in wrap_commands
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 2264, in resolve
File "/Users/viki/anaconda3/lib/python3.5/site-packages/Sphinx-1.4.6-py3.5.egg/sphinx/setup_command.py", line 23, in <module>
from sphinx.application import Sphinx
File "/Users/viki/anaconda3/lib/python3.5/site-packages/Sphinx-1.4.6-py3.5.egg/sphinx/application.py", line 26, in <module>
from docutils.parsers.rst import convert_directive_function, \
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/parsers/rst/__init__.py", line 74, in <module>
import docutils.statemachine
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/statemachine.py", line 113, in <module>
from docutils import utils
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/Users/viki/anaconda3/lib/python3.5/locale.py", line 577, in getlocale
return _parse_localename(localename)
File "/Users/viki/anaconda3/lib/python3.5/locale.py", line 486, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/pip-build-01z4855a/virtualenvwrapper/setup.py", line 7, in <module>
pbr=True,
File "/Users/viki/anaconda3/lib/python3.5/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 315, in __init__
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 361, in fetch_build_eggs
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 851, in resolve
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 1123, in best_match
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 1135, in obtain
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 428, in fetch_build_egg
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 664, in easy_install
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 694, in install_item
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 875, in install_eggs
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1114, in build_and_install
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1100, in run_setup
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 249, in run_setup
File "/Users/viki/anaconda3/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
File "/Users/viki/anaconda3/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 168, in save_modules
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 143, in resume
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/_vendor/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 156, in save_modules
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 246, in run_setup
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 276, in run
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 245, in runner
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 47, in _execfile
File "/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/easy_install-ff5qsxzn/pbr-1.10.0/setup.py", line 22, in <module>
File "/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/easy_install-ff5qsxzn/pbr-1.10.0/pbr/util.py", line 264, in cfg_to_args
File "/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/easy_install-ff5qsxzn/pbr-1.10.0/pbr/util.py", line 566, in wrap_commands
File "/Users/viki/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 2264, in resolve
File "/Users/viki/anaconda3/lib/python3.5/site-packages/Sphinx-1.4.6-py3.5.egg/sphinx/setup_command.py", line 23, in <module>
from sphinx.application import Sphinx
File "/Users/viki/anaconda3/lib/python3.5/site-packages/Sphinx-1.4.6-py3.5.egg/sphinx/application.py", line 26, in <module>
from docutils.parsers.rst import convert_directive_function, \
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/parsers/rst/__init__.py", line 74, in <module>
import docutils.statemachine
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/statemachine.py", line 113, in <module>
from docutils import utils
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Users/viki/anaconda3/lib/python3.5/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/Users/viki/anaconda3/lib/python3.5/locale.py", line 577, in getlocale
return _parse_localename(localename)
File "/Users/viki/anaconda3/lib/python3.5/locale.py", line 486, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/xp/xcwv5f6s05g2381pc4_vvbs80000gn/T/pip-build-01z4855a/virtualenvwrapper/
--
Was trying to figure out why this was happening and finally found that the issue is something to do with LANG settings with zsh.
The solution was pretty simple though:
I just added the following lines in ~/.zshrc
export WORKON_HOME=~/.virtualenvs
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
and ran
source ~/.zshrc
After which I re-ran
pip install virtualenvwrapper
and it worked.
But later while creating virtualenv I faced a different issue:
export WORKON_HOME=~/.virtualenvsFor anaconda + virtualenv
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh
Add following line to ~/.zshrc
source "/Users/viki/anaconda3/bin/virtualenvwrapper.sh"
➜ source ~/.zshrc
➜ mkvirtualenv env1
Using base prefix '/Users/viki/anaconda3'
New python executable in /Users/viki/.virtualenvs/env1/bin/python
dyld: Library not loaded: @rpath/libpython3.5m.dylib
Referenced from: /Users/viki/.virtualenvs/env1/bin/python
Reason: image not found
ERROR: The executable /Users/viki/.virtualenvs/env1/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/viki/.virtualenvs' (should be '/Users/viki/.virtualenvs/env1')
ERROR: virtualenv is not compatible with this system or executable
The above does not work. And I don't know the exact reason.
But it has something to do with symlinking to the system level python env that is not the same as symlinking to anaconda env.
To resolve the above issue you can specify the python version to be used in the virtualenv
mkvirtualenv -p /usr/bin/python2.7 env1This finally worked.
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /Users/viki/.virtualenvs/env1/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/viki/.virtualenvs/env1/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/viki/.virtualenvs/env1/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/viki/.virtualenvs/env1/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/viki/.virtualenvs/env1/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/viki/.virtualenvs/env1/bin/get_env_details
Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.
--
Happy :)
No comments:
Post a Comment