mac中,之前已存在一个pipenv的文件:
<code>[[source]] url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" [packages] pymysql = "*" mysql = "*" mysqlclient = "*" mysql-connector-python = "*" [dev-packages] [requires] python_version = "3.6" </code>
现在去进入环境,结果出错:
<code>➜ AutocarData pipenv shell Traceback (most recent call last): File "/Users/crifan/Library/Python/2.7/bin/pipenv", line 11, in <module> sys.exit(cli()) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 717, in main rv = self.invoke(ctx) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/cli/command.py", line 374, in shell pypi_mirror=state.pypi_mirror, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 2069, in do_shell ensure_project(three=three, python=python, validate=False, pypi_mirror=pypi_mirror) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 565, in ensure_project pypi_mirror=pypi_mirror, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 483, in ensure_virtualenv if not project.virtualenv_exists: File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 259, in virtualenv_exists if self.pipfile_exists and os.path.exists(self.virtualenv_location): File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 398, in virtualenv_location self._virtualenv_location = self.get_location_for_virtualenv() File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 272, in get_location_for_virtualenv name = self.virtualenv_name File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 384, in virtualenv_name sanitized, encoded_hash = self._get_virtualenv_hash(self.name) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 353, in _get_virtualenv_hash clean_name, encoded_hash = get_name(name, self.pipfile_location) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 349, in get_name hash = hashlib.sha256(location.encode()).digest()[:6] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 36: ordinal not in range(128) </code>
然后:
<code>➜ AutocarData pipenv install Traceback (most recent call last): File "/Users/crifan/Library/Python/2.7/bin/pipenv", line 11, in <module> sys.exit(cli()) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 717, in main rv = self.invoke(ctx) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/cli/command.py", line 249, in install editable_packages=state.installstate.editables, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 1724, in do_install pypi_mirror=pypi_mirror, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 565, in ensure_project pypi_mirror=pypi_mirror, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 483, in ensure_virtualenv if not project.virtualenv_exists: File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 259, in virtualenv_exists if self.pipfile_exists and os.path.exists(self.virtualenv_location): File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 398, in virtualenv_location self._virtualenv_location = self.get_location_for_virtualenv() File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 272, in get_location_for_virtualenv name = self.virtualenv_name File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 384, in virtualenv_name sanitized, encoded_hash = self._get_virtualenv_hash(self.name) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 353, in _get_virtualenv_hash clean_name, encoded_hash = get_name(name, self.pipfile_location) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 349, in get_name hash = hashlib.sha256(location.encode()).digest()[:6] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 36: ordinal not in range(128) /Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/vistir/compat.py:109: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pipenv-Erc0CX-requirements'> warnings.warn(warn_message, ResourceWarning) ➜ AutocarData pip install pipenv Requirement already satisfied: pipenv in /Users/crifan/Library/Python/2.7/lib/python/site-packages (2018.10.13) Requirement already satisfied: setuptools>=36.2.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (39.0.1) Requirement already satisfied: virtualenv in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (16.0.0) Requirement already satisfied: enum34; python_version < "3" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (1.1.6) Requirement already satisfied: pip>=9.0.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (10.0.1) Requirement already satisfied: typing; python_version < "3.5" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (3.6.6) Requirement already satisfied: certifi in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (2018.8.24) Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (0.3.0) matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is not installed. pyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible. You are using pip version 10.0.1, however version 19.0.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command. ➜ AutocarData pip3 install pipenv Requirement already satisfied: pipenv in /Users/crifan/Library/Python/3.6/lib/python/site-packages (2018.7.1) Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (10.0.1) Requirement already satisfied: certifi in /Users/crifan/Library/Python/3.6/lib/python/site-packages (from pipenv) (2018.4.16) Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/3.6/lib/python/site-packages (from pipenv) (0.3.0) Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (38.5.2) Requirement already satisfied: virtualenv in /Users/crifan/Library/Python/3.6/lib/python/site-packages (from pipenv) (15.2.0) Cache entry deserialization failed, entry ignored You are using pip version 10.0.1, however version 19.0.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command. ➜ AutocarData pipenv shell Traceback (most recent call last): File "/Users/crifan/Library/Python/2.7/bin/pipenv", line 11, in <module> sys.exit(cli()) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 717, in main rv = self.invoke(ctx) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/cli/command.py", line 374, in shell pypi_mirror=state.pypi_mirror, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 2069, in do_shell ensure_project(three=three, python=python, validate=False, pypi_mirror=pypi_mirror) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 565, in ensure_project pypi_mirror=pypi_mirror, File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/core.py", line 483, in ensure_virtualenv if not project.virtualenv_exists: File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 259, in virtualenv_exists if self.pipfile_exists and os.path.exists(self.virtualenv_location): File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 398, in virtualenv_location self._virtualenv_location = self.get_location_for_virtualenv() File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 272, in get_location_for_virtualenv name = self.virtualenv_name File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 384, in virtualenv_name sanitized, encoded_hash = self._get_virtualenv_hash(self.name) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 353, in _get_virtualenv_hash clean_name, encoded_hash = get_name(name, self.pipfile_location) File "/Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/project.py", line 349, in get_name hash = hashlib.sha256(location.encode()).digest()[:6] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 36: ordinal not in range(128) ➜ AutocarData pip install --upgrade pip Collecting pip Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is not installed. pyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible. Installing collected packages: pip Found existing installation: pip 10.0.1 Uninstalling pip-10.0.1: Successfully uninstalled pip-10.0.1 Rolling back uninstall of pip Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip' Consider using the `--user` option or check the permissions. You are using pip version 10.0.1, however version 19.0.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command. ➜ AutocarData pip install --upgrade pip --user Collecting pip Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is not installed. pyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible. Installing collected packages: pip Found existing installation: pip 10.0.1 Uninstalling pip-10.0.1: Successfully uninstalled pip-10.0.1 Successfully installed pip-19.0.3 </code>
结果问题依旧。
mac pipenv UnicodeDecodeError ascii codec can’t decode byte 0xe6 in position 36: ordinal not in range(128)
pip install fails on OSX · Issue #713 · enthought/mayavi
mac pipenv project.py UnicodeDecodeError ascii codec can’t decode byte
UnicodeDecodeError when installing ansible · Issue #623 · pypa/pipenv
我此处现象:
<code>➜ AutocarData echo $LANG zh_CN.UTF-8 ➜ AutocarData echo $LC_CTYPE zh_CN.UTF-8 ➜ AutocarData echo $LC_MESSAGES ➜ AutocarData echo $LC_COLLATE ➜ AutocarData </code>
“pip issue, not pipenv issue”
mac pip UnicodeDecodeError ascii codec can’t decode byte
python – PIP Install Numpy throws an error “ascii codec can’t decode byte 0xe2” – Stack Overflow
python – ‘ascii’ codec can’t decode error when use pip to install uwsgi – Stack Overflow
卸载后pipenv后重新安装
<code>➜ AutocarData pip uninstall pipenv DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Uninstalling pipenv-2018.10.13: Would remove: /Users/crifan/Library/Python/2.7/bin/pipenv /Users/crifan/Library/Python/2.7/bin/pipenv-resolver /Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv-2018.10.13.dist-info/* /Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/* Proceed (y/n)? y Successfully uninstalled pipenv-2018.10.13 ➜ AutocarData pip install pipenv DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting pipenv Downloading https://files.pythonhosted.org/packages/bb/15/b155a5c0d19ce41609f50bb70a37e0de092b453ec4bd2eac59e53a2c3227/pipenv-2018.11.26-py2-none-any.whl (5.2MB) 100% |████████████████████████████████| 5.2MB 11kB/s Requirement already satisfied: setuptools>=36.2.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (39.0.1) Requirement already satisfied: virtualenv in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (16.0.0) Requirement already satisfied: enum34; python_version < "3" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (1.1.6) Requirement already satisfied: pip>=9.0.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (19.0.3) Requirement already satisfied: typing; python_version < "3.5" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (3.6.6) Requirement already satisfied: certifi in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (2018.8.24) Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (0.3.0) Installing collected packages: pipenv Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pipenv-2018.11.26.dist-info' Consider using the `--user` option or check the permissions. ➜ AutocarData pip install pipenv --user DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting pipenv Using cached https://files.pythonhosted.org/packages/bb/15/b155a5c0d19ce41609f50bb70a37e0de092b453ec4bd2eac59e53a2c3227/pipenv-2018.11.26-py2-none-any.whl Requirement already satisfied: setuptools>=36.2.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (39.0.1) Requirement already satisfied: virtualenv in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (16.0.0) Requirement already satisfied: enum34; python_version < "3" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (1.1.6) Requirement already satisfied: pip>=9.0.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (19.0.3) Requirement already satisfied: typing; python_version < "3.5" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (3.6.6) Requirement already satisfied: certifi in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (2018.8.24) Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (0.3.0) Installing collected packages: pipenv Successfully installed pipenv-2018.11.26 </code>
Non-ascii error with pip install · Issue #2501 · pypa/pip
再去试试,问题依旧:
<code>➜ AutocarData pipenv uninstall pipenv ➜ AutocarData pip uninstall pipenv DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Uninstalling pipenv-2018.11.26: Would remove: /Users/crifan/Library/Python/2.7/bin/pipenv /Users/crifan/Library/Python/2.7/bin/pipenv-resolver /Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv-2018.11.26.dist-info/* /Users/crifan/Library/Python/2.7/lib/python/site-packages/pipenv/* Proceed (y/n)? y Successfully uninstalled pipenv-2018.11.26 ➜ AutocarData pip3 install pipenv Requirement already satisfied: pipenv in /Users/crifan/Library/Python/3.6/lib/python/site-packages (2018.7.1) Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (38.5.2) Requirement already satisfied: virtualenv in /Users/crifan/Library/Python/3.6/lib/python/site-packages (from pipenv) (15.2.0) Requirement already satisfied: certifi in /Users/crifan/Library/Python/3.6/lib/python/site-packages (from pipenv) (2018.4.16) Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/3.6/lib/python/site-packages (from pipenv) (0.3.0) Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (10.0.1) You are using pip version 10.0.1, however version 19.0.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command. </code>
看看版本:
<code>➜ AutocarData which pipenv /Users/crifan/Library/Python/3.6/bin/pipenv ➜ AutocarData pipenv --version pipenv, version 2018.7.1 </code>
再去试试:
<code>➜ AutocarData pipenv shell Launching subshell in virtual environment… . /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/bin/activate ➜ AutocarData . /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/bin/activate ➜ AutocarData </code>
就可以了。
【总结】
mac中,此处用pipenv shell出错,
原因:未知。
感觉是:pipenv是之前旧的python 2的pipenv。
但是也不该出错,不知道到底为何会出错。
解决办法:
卸载旧的(估计是Python 2的)pipenv:pip uninstall pipenv
安装新的Python 3的pipenv:pip3 install pipenv
即可:
<code>pipenv shell </code>
正常启用环境。
转载请注明:在路上 » 【已解决】Mac中pipenv shell出错:UnicodeDecodeError ascii codec can’t decode byte 0xe6 in position ordinal not in range 128