I am having a special setup. I have a docker in which I create an emulated ARM rootfs using QEMU. Inside the emulated rootfs , I am going to create a virtual environment using pipenv which I can use later on my ARM target.
What is happening now is that I am always receiving the following exception:
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 416, in install
selective_upgrade=selective_upgrade,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1789, in do_install
skip_requirements=skip_requirements,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 641, in ensure_project
crayons.green(shorten_path(path_to_python)),
TypeError: __str__ returned non-string (type NoneType)
As I traced the exception, I found out that problem here is that the python_version() method returns None in my case. Then as I use docker exec
to run pipenv install
, I think I am mixing different shell environment, therefore crayons.green cannot convert None type to string. My proposal would be simply just use str
in all crayons e.g. crayons.green(str(python_version(path_to_python)))
Please tell us all of the information about the pipenv version running in your environment, per the issue template,
I realize it may seem intuitive to you what is happening, but pipenv is super complex and what you think is happening is probably more involved than you're suggesting, so before we jump to any conclusions or start deciding what the solution is, it would be good to diagnose the problem
Well, of course it was a proposal to give you little bit more information about hot fix which I made after spending hours on checking from top to down in docker and QEMU emulator. However, I am using pipenv version 2018.7.1
and python version 3.6.3
in the emulator.
Wild guess, does setting PIPENV_COLORBLIND
inside the emulator work? Maybe QEMU doesn’t like ANSI colour codes.
https://docs.pipenv.org/advanced/#pipenv.environments.PIPENV_COLORBLIND
I just tried with PIPENV_COLORBLIND
set. I have the same issue again. What I have to add is that when I manually log into my docker container and manually run pipenv install
in the emulated QEMU rootfs, everything is fine and it works, but as soon as I try the same thing using docker exec
outside of the docker, I will have the exception. The point is that crayons
once can get __str__
out of None
, but not in the case when I use docker exec
!
I think I kind of know what the root problem is. Crayon can only return None when the input is None, which means that ultimately path_to_python
is None, which leads us back to system_which
returning None… this problem, maybe?
https://docs.pipenv.org/diagnose/#valueerror-unknown-locale-utf-8
Actually the path_to_python
is equal /usr/bin/python
when it is delivered to utils.python_version
. I do not know what happens there that utils.python_version
returns None. As I said before, crayons
can only handle strings, and what is unclear for me is the point that in one way it is able to get "None"
out of None.__str__
, but not in the other way.
Literally _no_ code paths in crayons can return None if the input string is not None. This error can only occur when path_to_python
is None. Believe me, or I can offer nothing else.
I have the same problem with python-3.7 and pipenv-2018.7.1:
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/cli.py", line 701, in run
do_run(command=command, args=args, three=three, python=python, pypi_mirror=pypi_mirror)
File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 2244, in do_run
ensure_project(three=three, python=python, validate=False, pypi_mirror=pypi_mirror)
File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 625, in ensure_project
crayons.green(shorten_path(path_to_python)),
TypeError: __str__ returned non-string (type NoneType)
Please fill out the issue template in full. The bug is not in crayons no matter how many times we see the same output. We have issue templates for a reason. I appreciate that everyone is taking time to troubleshoot, we also spent months (or years) building the library and if you can't spend the time to fill out an issue template we can't offer you any support.
Here are two other issues addressing the same problem: #2650, #1969 . And as already mentioned something in detection of used python version is broken. For me adding --system
(pipenv install --system
) solved the issue.
What does "System pip management" mean (from the documentation of the --system
flag)?
Same problem here, working within a Docker container.
Host environment is:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
$ docker --version
Docker version 18.09.7, build 2d0083d
$ docker-compose --version
docker-compose version 1.25.4, build unknown
Python container is based on
FROM python:3.7-slim-buster
and it uses the following pipenv
version:
pipenv = "==2018.11.26"
Most helpful comment
Here are two other issues addressing the same problem: #2650, #1969 . And as already mentioned something in detection of used python version is broken. For me adding
--system
(pipenv install --system
) solved the issue.