Home
Support Forums

Pipenv Install Error with Python 2.7

I noticed that sometime after march I started getting build failures where the build would fail to perform a pipenv install. I think this is due to a mismatch between my requested python version and the pipenv runtime python version. I have tried setting the python version in my Pipfile, using the PYTHON_VERSION environment variable, and with runtime.txt and none of these changed the outcome. I noticed that in March another user had the same error, and switched to Poetry to avoid the problem (Automatic build fails, but manually triggered builds work). My builds do not succeed even when the cache is cleared unlike the other user.

Ideally this could be resolved and I could continue using Pipenv. Any help would be appreciated.

netlify site: adoring-mcclintock-99499e

11:58:29 PM: Waiting for other deploys from your team to complete. Check the queue: https://app.netlify.com/teams/adkinsjd/builds
11:59:18 PM: Build ready to start
11:59:20 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
11:59:20 PM: build-image tag: v3.8.0
11:59:20 PM: buildbot version: b7aeb2675f82192daa8545b22bebab9c3b179d0e
11:59:20 PM: Building without cache
11:59:20 PM: Starting to prepare the repo for build
11:59:21 PM: No cached dependencies found. Cloning fresh repo
11:59:21 PM: git clone https://github.com/nline/powerwatch-data-analysis
11:59:44 PM: Preparing Git Reference refs/heads/adkins/add-documentation
11:59:45 PM: Parsing package.json dependencies
11:59:46 PM: Starting build script
11:59:46 PM: Installing dependencies
11:59:46 PM: Found Pipfile restoring Pipenv virtualenv
11:59:46 PM: Started restoring cached python virtualenv
11:59:46 PM: Finished restoring cached python virtualenv
11:59:47 PM: v12.18.0 is already installed.
11:59:47 PM: Now using node v12.18.0 (npm v6.14.4)
11:59:47 PM: Started restoring cached build plugins
11:59:47 PM: Finished restoring cached build plugins
11:59:47 PM: Attempting ruby version 2.7.1, read from environment
11:59:48 PM: Required ruby-2.7.1 is not installed - installing.
11:59:49 PM: Searching for binary rubies, this might take some time.
11:59:49 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.7.1.tar.bz2
11:59:49 PM: Checking requirements for ubuntu.
11:59:49 PM: Requirements installation successful.
11:59:49 PM: ruby-2.7.1 - #configure
11:59:49 PM: ruby-2.7.1 - #download
11:59:51 PM: ruby-2.7.1 - #validate archive
11:59:55 PM: ruby-2.7.1 - #extract
11:59:57 PM: ruby-2.7.1 - #validate binary
11:59:58 PM: ruby-2.7.1 - #setup
11:59:59 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1@global
11:59:59 PM: ruby-2.7.1 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
11:59:59 PM: ruby-2.7.1 - #generating global wrappers........
11:59:59 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1
11:59:59 PM: ruby-2.7.1 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
12:00:00 AM: ruby-2.7.1 - #generating default wrappers........
12:00:00 AM: Using /opt/buildhome/.rvm/gems/ruby-2.7.1
12:00:01 AM: Using ruby version 2.7.1
12:00:01 AM: Using PHP version 5.6
12:00:01 AM: Installing dependencies from Pipfile
12:00:02 AM: Creating a virtualenv for this project...
12:00:02 AM: Pipfile: /opt/build/repo/Pipfile
12:00:02 AM: Using /usr/bin/python3.7m (3.7.10) to create virtualenv...
12:00:05 AM: created virtual environment CPython3.7.10.final.0-64 in 2438ms
12:00:05 AM:   creator CPython3Posix(dest=/opt/build/repo/.venv, clear=False, no_vcs_ignore=False, global=False)
12:00:05 AM:   seeder FromAppData(download=False, pip=bundle, wheel=bundle, setuptools=bundle, via=copy, app_data_dir=/opt/buildhome/.local/share/virtualenv)
12:00:05 AM:     added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
12:00:05 AM:   activators PythonActivator,FishActivator,XonshActivator,CShellActivator,PowerShellActivator,BashActivator
12:00:05 AM: Successfully created virtual environment!
12:00:05 AM: Virtualenv location: /opt/build/repo/.venv
12:00:05 AM: Installing dependencies from Pipfile.lock (9af4e4)...
12:00:10 AM: Traceback (most recent call last):
12:00:10 AM:   File "/opt/buildhome/python2.7/bin/pipenv", line 8, in <module>
12:00:10 AM:     sys.exit(cli())
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
12:00:10 AM:     return self.main(*args, **kwargs)
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 782, in main
12:00:10 AM:     rv = self.invoke(ctx)
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke
12:00:10 AM:     return _process_result(sub_ctx.command.invoke(sub_ctx))
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
12:00:10 AM: Creating deploy upload records
12:00:10 AM:     return ctx.invoke(self.callback, **ctx.params)
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
12:00:10 AM:     return callback(*args, **kwargs)
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
12:00:10 AM:     return ctx.invoke(f, obj, *args, **kwargs)
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
12:00:10 AM:     return callback(*args, **kwargs)
12:00:10 AM:   File "/opt/buildhome/python2.7/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func
12:00:10 AM:     return f(get_current_context(), *args, **kwargs)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/cli/command.py", line 253, in install
12:00:10 AM:     site_packages=state.site_packages
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/core.py", line 2063, in do_install
12:00:10 AM:     keep_outdated=keep_outdated
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/core.py", line 1312, in do_init
12:00:10 AM:     pypi_mirror=pypi_mirror,
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/core.py", line 842, in do_install_dependencies
12:00:10 AM:     deps_list = list(lockfile.get_requirements(dev=dev, only=dev_only))
12:00:10 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/lockfile.py", line 273, in get_requirements
12:00:10 AM:     yield Requirement.from_pipfile(k, v)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 2747, in from_pipfile
12:00:10 AM:     r = FileRequirement.from_pipfile(name, pipfile)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 1842, in from_pipfile
12:00:10 AM:     arg_dict["setup_info"] = arg_dict["parsed_line"].setup_info
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 806, in setup_info
12:00:10 AM:     self.setup_info = self.get_setup_info()
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 795, in get_setup_info
12:00:10 AM:     setup_info = SetupInfo.from_ireq(self.ireq, subdir=self.subdirectory)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/backports/functools_lru_cache.py", line 149, in wrapper
12:00:10 AM:     result = user_function(*args, **kwds)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1951, in from_ireq
12:00:10 AM:     ireq.source_dir, subdirectory=subdir, ireq=ireq, kwargs=kwargs, stack=stack
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1987, in create
12:00:10 AM:     created.get_initial_info()
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1816, in get_initial_info
12:00:10 AM:     self.update_from_dict(self.parse_setup_py())
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1514, in update_from_dict
12:00:10 AM:     for section in set(list(extras_require.keys())) - set(list(self.extras.keys())):
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1442, in extras
12:00:10 AM:     self.get_info()
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1834, in get_info
12:00:10 AM:     self.build()
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1696, in build
12:00:10 AM:     return self.run_setup()
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1567, in run_setup
12:00:10 AM:     dist = run_setup(self.setup_py.as_posix(), egg_base=self.egg_base)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1324, in run_setup
12:00:10 AM:     _setup_distribution = get_metadata(egg_base, metadata_type="egg")
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 569, in get_metadata
12:00:10 AM:     dist = get_egginfo_dist(path, pkg_name=pkg_name)
12:00:10 AM:   File "/opt/buildhome/python2.7/local/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 554, in get_egginfo_dist
12:00:10 AM:     dist_iter = pkg_resources.distributions_from_metadata(path_metadata.egg_info)
12:00:10 AM: AttributeError: 'module' object has no attribute 'distributions_from_metadata'
12:00:10 AM: Error installing Pipenv dependencies
12:00:10 AM: Please see https://github.com/netlify/build-image/#included-software for current versions
12:00:10 AM: Build was terminated: Build script returned non-zero exit code: 1
12:00:10 AM: Failing build: Failed to build site
12:00:10 AM: Finished processing build request in 50.384914714s

I was able to fix this problem for now by changing my base directory to one without my Pipfile, then creating a script that upgrades setuptools to the newest version, installs pipenv using python 3.7, then finally installs the pipenv dependencies before performing my usual build tasks.