pypa / build

A simple, correct Python build frontend
https://build.pypa.io
MIT License
727 stars 121 forks source link

Getting error : returned non-zero exit status 1 #447

Open Simeon2001 opened 2 years ago

Simeon2001 commented 2 years ago

am trying to run python -m build and am getting this error:

* Creating venv isolated environment...

Traceback (most recent call last):
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\site-packages\build\__main__.py", line 372, in main        
    built = build_call(
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\site-packages\build\__main__.py", line 229, in build_package_via_sdist
    sdist = _build(isolation, builder, outdir, 'sdist', config_settings, skip_dependency_check)
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\site-packages\build\__main__.py", line 140, in _build      
    return _build_in_isolated_env(builder, outdir, distribution, config_settings)
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\site-packages\build\__main__.py", line 104, in _build_in_isolated_env
    with _IsolatedEnvBuilder() as env:
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\site-packages\build\env.py", line 104, in __enter__        
    executable, scripts_dir = _create_isolated_env_venv(self._path)
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\site-packages\build\env.py", line 257, in _create_isolated_env_venv
    venv.EnvBuilder(with_pip=True, symlinks=_fs_supports_symlink()).create(path)
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\venv\__init__.py", line 75, in create
    self._setup_pip(context)
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\venv\__init__.py", line 298, in _setup_pip
    subprocess.check_output(cmd, stderr=subprocess.STDOUT)
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\Toshiba\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\Users\\Toshiba\\AppData\\Local\\Temp\\build-env-3ia9055n\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

ERROR Command '['C:\\Users\\Toshiba\\AppData\\Local\\Temp\\build-env-3ia9055n\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
henryiii commented 2 years ago

Can you try the latest main branch of build? I think the error might be nicer there.

lien-Gu commented 1 year ago

i met the same error, my python=3.7, pip version=22.3.1, operating system is Windows. it said cann't get hatchling/ because of SSL error, but i come to the source site where does exists hatchling from 0.10.0 to 1.9.0 and also i can install other modules(include build0.10.0) using my pip. Looking forward to your help. Here is the log:

* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (hatchling)
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS U
RL because the SSL module is not available.")': /simple/hatchling/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS U
RL because the SSL module is not available.")': /simple/hatchling/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS U
RL because the SSL module is not available.")': /simple/hatchling/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS U
RL because the SSL module is not available.")': /simple/hatchling/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS U
RL because the SSL module is not available.")': /simple/hatchling/
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/hatchling/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=
'pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/hatchling/ (Caused by SSLError("Can't connect to HTTPS URL because the 
SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement hatchling (from versions: none)
ERROR: No matching distribution found for hatchling
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.
tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module i
s not available.")) - skipping
WARNING: There was an error checking the latest version of pip.

Traceback (most recent call last):
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\__main__.py", line 375, in main
    built = build_call(
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\__main__.py", line 235, in build_package_via_sdist
    sdist = _build(isolation, builder, outdir, 'sdist', config_settings, skip_dependency_check)
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\__main__.py", line 145, in _build
    return _build_in_isolated_env(builder, outdir, distribution, config_settings)
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\__main__.py", line 113, in _build_in_isolated_env
    env.install(builder.build_system_requires)
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\env.py", line 214, in install
    _subprocess(cmd)
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\env.py", line 79, in _subprocess
    raise e
  File "D:\code_setting\conda\envs\pub_list_py38\lib\site-packages\build\env.py", line 76, in _subprocess
    subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "D:\code_setting\conda\envs\pub_list_py38\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\Users\\admin\\AppData\\Local\\Temp\\build-env-mln_gg6l\\Scripts\\python.exe', '-Im', 'pip', 'install', '
--use-pep517', '--no-warn-script-location', '-r', 'C:\\Users\\admin\\AppData\\Local\\Temp\\build-reqs-jmxm5gql.txt']' returned non-zero exit status 1.

ERROR Command '['C:\\Users\\admin\\AppData\\Local\\Temp\\build-env-mln_gg6l\\Scripts\\python.exe', '-Im', 'pip', 'install', '--use-pep517', '--no-warn
-script-location', '-r', 'C:\\Users\\admin\\AppData\\Local\\Temp\\build-reqs-jmxm5gql.txt']' returned non-zero exit status 1.
mattgleesonmicrosoft commented 1 year ago

Hi @lien-Gu @henryiii I am getting the same error. Just like you, I am able to install packages using pip however it fails with "WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available." when using the build module. It popped up randomly this week and I have tried all solutions I could find on the internet such as this one: https://stackoverflow.com/questions/45954528/pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl-module-in.

Were you able to solve your problem?

henryiii commented 1 year ago

For a quick possible fix, you can try using build[virtualenv] when you install build - that will use a modern, up-to-date copy of pip. Another option is to use -n / --no-isolation when building, which will use your current environment instead of creating one and installing everything you need in it.

Do you have any special PIP_* variables set?

mattgleesonmicrosoft commented 1 year ago

Hey @henryiii , thanks for the quick suggestions! build[virtualenv] did not work but --no-isolation option does build successfully. I think this points towards some sort of problem with the virtualenv interpreter not having access to/having a malformed ssl module. Will update this thread if I find a fix

gschlafly commented 1 year ago

I was getting the same error message using python 3.9.16 on Windows OS. Trying to install build[virtualenv] as @henryiii suggested did not work either. I was in a conda environment. After deactivating the environment, python -m build worked as expected. That may work for you! @lien-Gu @mattgleesonmicrosoft

ikost commented 1 year ago

I confirm to have similar problem when running the build offline. When on Internet - everything works fine. Why would one need Internet connection to build the sdist?Hmm..

henryiii commented 1 year ago

You need the Internet to get packages to set up the isolated virtual environment, which is the default. If you want to manually install all of the build dependencies for the package you want to build an SDist for yourself (setuptools or flit or poetry or something else), you can use the no isolated environment flag.