0
votes

I don't know why I can't create virutalenv for my projects.

I create the folder and type the command to install Django

pipenv install Django

But I have an error I can't identify what is it.

Warning: the environment variable LANG is not set! We recommend setting this in ~/.profile (or equivalent) for proper expected behavior. Creating a virtualenv for this project... Pipfile: /Users/pedrosantos/Desktop/helloworld/Pipfile Using /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 (3.6.6) to create virtualenv... ⠋Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/pew/main.py", line 8, in import pew File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/patched/pew/init.py", line 3, in from . import pew File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/patched/pew/pew.py", line 44, in from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/patched/pew/_utils.py", line 25, in encoding = locale.getlocale()[1] or 'ascii' File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 581, in getlocale return _parse_localename(localename) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 490, in _parse_localename raise ValueError('unknown locale: %s' % localename) ValueError: unknown locale: UTF-8

Virtualenv location: Creating a Pipfile for this project... Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv", line 11, in sys.exit(cli()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in call return self.main(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main rv = self.invoke(ctx) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/cli.py", line 435, in install selective_upgrade=selective_upgrade, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 1759, in do_install pypi_mirror=pypi_mirror, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 639, in ensure_project ensure_pipfile(validate=validate, skip_requirements=skip_requirements, system=system) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 288, in ensure_pipfile project.create_pipfile(python=python) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/project.py", line 607, in create_pipfile required_python = self.which('python') File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 115, in which p = os.path.join(location, 'bin', command) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/posixpath.py", line 80, in join a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType

So sorry, I am beginner in Django and I am following the Willian S. Vicent book (Django 2.0)

After that the book ask to type:

$ pipenv shell

and start my project. I could do it before, but now I don't know what is happening.

Thanks,

1

1 Answers

2
votes

This is a common issue in MacOS, The issue is mentioned here a long with the solution. https://pipenv.kennethreitz.org/diagnose/#valueerror-unknown-locale-utf-8

To make the long story short, There are some variables are missing in your machine which are LC_ALL and LANG. You have to add this to your ~/.bash_profile file.

so what you need to do is open this file with your favorit editor and add those line

export LC_ALL='en_US.UTF-8'
export LANG='en_US.UTF-8'

After you add those Env Variables, you will need to re activate this file. So you need to run

> source ~/.bash_profile