Skip to content

Can't download setuptools #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
minchinweb opened this issue Oct 12, 2015 · 11 comments
Closed

Can't download setuptools #807

minchinweb opened this issue Oct 12, 2015 · 11 comments

Comments

@minchinweb
Copy link

virtualenv fails to create the virtual environment as it seems unable to find setuptools to download an install in.

Python 3.5.0, system install, WIndows 10, virtualenv 1.3.2 13.1.2

virtualenv works as expected on the same machine using Python 3.4.3.

This is the output:

> virtualenv env5
Using base prefix 'c:\\program files\\python 3.5'
New python executable in env5\Scripts\python.exe
Installing setuptools, pip, wheel...
  Complete output from command C:\Users\User\Docume...5\Scripts\python.exe -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  The repository located at None is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host None'.
  Could not find a version that satisfies the requirement setuptools (from versions: )
No matching distribution found for setuptools
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "c:\program files\python 3.5\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python 3.5\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python 3.5\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
  File "c:\program files\python 3.5\lib\site-packages\virtualenv.py", line 832, in main
    symlink=options.symlink)
  File "c:\program files\python 3.5\lib\site-packages\virtualenv.py", line 1004, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "c:\program files\python 3.5\lib\site-packages\virtualenv.py", line 969, in install_wheel
    'PIP_NO_INDEX': '1'
  File "c:\program files\python 3.5\lib\site-packages\virtualenv.py", line 910, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command C:\Users\User\Docume...5\Scripts\python.exe -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
@Ivoz
Copy link

Ivoz commented Oct 13, 2015

Could you confirm the virtualenv version that you used? The latest is 13.1.2, but the one you specified, 1.3.2, was released in December 2008. If you did use 1.3.2 I'd encourage you to update to the latest stable release.

@Ivoz Ivoz added the question label Oct 13, 2015
@minchinweb
Copy link
Author

I guess it was really late...

I'm using virtualenv 13.1.2 and have also reproduced the issue with 13.1.1.

@Ivoz Ivoz added windows and removed question labels Oct 14, 2015
@efagerberg
Copy link

Hello this is also happening to myself as well.
From what I have heard this may be because the path under your python directory has a space in it.

So I tested this by removing my install of python from under my username folder (had a space) to under my C drive. Once you do this it should work for you @minchinweb .

@minchinweb
Copy link
Author

@efagerberg I think you're right. If I create a virtual environment with Python 3.4, activate it, and then try to run virtualenv from there (so the Python execacutable is at C:\tmp\some d\env4\Scripts\Python.exe), it fails with the same issue.

@minchinweb
Copy link
Author

If it's helpful, here are the results of virtualenv's tests. I cloned the current version (cba89a1), and navigated to the root directory.

S:\Documents\GitHub\virtualenv\>py.test
============================= test session starts =============================
platform win32 -- Python 3.5.0, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: S:\Documents\GitHub\virtualenv, inifile: 
collected 9 items

test.txt s
tests\test_virtualenv.py .F.F....

================================== FAILURES ===================================
_________________ test_resolve_interpreter_with_absolute_path _________________

mock_exists = <MagicMock name='exists' id='414201680728'>

    @patch('os.path.exists')
    def test_resolve_interpreter_with_absolute_path(mock_exists):
        """Should return absolute path if given and exists"""
        mock_exists.return_value = True
        virtualenv.is_executable = Mock(return_value=True)

        exe = virtualenv.resolve_interpreter("/usr/bin/python42")

>       assert exe == "/usr/bin/python42", "Absolute path should return as is"
E       AssertionError: Absolute path should return as is
E       assert 'C:/usr/bin/python42' == '/usr/bin/python42'
E         - C:/usr/bin/python42
E         ? --
E         + /usr/bin/python42

tests\test_virtualenv.py:26: AssertionError
______________ test_resolve_interpreter_with_invalid_interpreter ______________

mock_exists = <MagicMock name='exists' id='414201836432'>

    @patch('os.path.exists')
    def test_resolve_interpreter_with_invalid_interpreter(mock_exists):
        """Should exit when with absolute path if not exists"""
        mock_exists.return_value = True
        virtualenv.is_executable = Mock(return_value=False)

        try:
            virtualenv.resolve_interpreter("/usr/bin/python42")
            assert False, "Should raise exception"
        except SystemExit:
            pass

>       mock_exists.assert_called_with("/usr/bin/python42")

tests\test_virtualenv.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\program files\python 3.5\lib\site-packages\mock\mock.py:937: in assert_called_with
    six.raise_from(AssertionError(_error_message(cause)), cause)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

value = AssertionError("Expected call: exists('/usr/bin/python42')\nActual call: exists('C:/usr/bin/python42')",)
from_value = None

>   ???
E   AssertionError: Expected call: exists('/usr/bin/python42')
E   Actual call: exists('C:/usr/bin/python42')

<string>:2: AssertionError
---------------------------- Captured stdout call -----------------------------
The executable C:/usr/bin/python42 (from --python=C:/usr/bin/python42) is not executable
=============== 2 failed, 6 passed, 1 skipped in 14.35 seconds ================

@frp
Copy link

frp commented Oct 26, 2015

For me, removing spaces fixes the problem. So the actual bug is in the code which processes paths.

@YSunLIN
Copy link

YSunLIN commented Nov 1, 2015

I found the bugs in the function install_wheel in virtualenv.py

def install_wheel(project_names, py_executable, search_dirs=None):
    if search_dirs is None:
        search_dirs = file_search_dirs()

    wheels = find_wheels(['setuptools', 'pip'], search_dirs)
    pythonpath = os.pathsep.join(wheels)
    findlinks = ' '.join(search_dirs)

    cmd = [
        py_executable, '-c',
        'import sys, pip; sys.exit(pip.main(["install", "--ignore-installed"] + sys.argv[1:]))'
    ] + project_names
    logger.start_progress('Installing %s...' % (', '.join(project_names)))
    logger.indent += 2
    try:
        call_subprocess(cmd, show_stdout=False,
            extra_env = {
                'PYTHONPATH': pythonpath,
                'JYTHONPATH': pythonpath,  # for Jython < 3.x
                'PIP_FIND_LINKS': findlinks,
                'PIP_USE_WHEEL': '1',
                'PIP_PRE': '1',
                'PIP_NO_INDEX': '1'
            }
        )
    finally:
        logger.indent -= 2
        logger.end_progress()
findlinks = ' '.join(search_dirs)

Here is the problem, search_dirs could include space, but they join search_dirs by space, OMG.
And the ultimate problem is that pip env varible PIP_FIND_LINKS doesn't support the space in windows path.
I think they will modify pip and virtualenv code in the same time to solve this issue.OMG.

My stupid solution is:
modify varible extra_env in this way

            extra_env = {
                'PYTHONPATH': pythonpath,
                'JYTHONPATH': pythonpath,  # for Jython < 3.x
                "PIP_INDEX_URL": "https://pypi.python.org/simple/",
                "PIP_TRUSTED_HOST": "pypi.python.org",
                # 'PIP_FIND_LINKS': findlinks,
                'PIP_USE_WHEEL': '1',
                # 'PIP_PRE': '1',
                # 'PIP_NO_INDEX': '1'
            }

@minchinweb
Copy link
Author

On Windows, when paths with a space are entered at the commandline, they have to be surrounded by quotes. I.e.

C:> cd "c:\some path with spaces\more"

Does PIP_FIND_LINKS work the same way? So pass it a string like:

C:\path1 C:\another_path C:\a\longer\path "C:\path with a space\more" C:\path2

@YSunLIN
Copy link

YSunLIN commented Nov 3, 2015

I have tried, and failed again.So I PIP_FIND_LINKS doesn't work in the same way actually.

@xflr6
Copy link

xflr6 commented Nov 12, 2015

Same problem here with Python 2.7 installed under C:\Program Files\Python27\:

C:\Users\User\Desktop>python -i -m virtualenv venv
(...)
OSError: Command C:\Users\User\Desktop\venv\Scripts\python.exe -c "import sys, p
ip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
>>> import pdb; pdb.pm()
> c:\program files\python27\lib\site-packages\virtualenv.py(910)call_subprocess()
-> % (cmd_desc, proc.returncode))
(Pdb) cmd
['C:\\Users\\User\\Desktop\\venv\\Scripts\\python.exe', '-c', 'import sys, pip;
sys.exit(pip.main(["install", "--ignore-installed"] + sys.argv[1:]))', 'setuptoo
ls', 'pip', 'wheel']
(Pdb) q
>>>

Workaround using Windows short path names (SPAM~1) in PIP_FIND_LINKS:

C:\Users\User\Desktop>virtualenv --no-setuptools venv
New python executable in venv\Scripts\python.exe

C:\Users\User\Desktop>set PIP_FIND_LINKS=c:\\PROGRA~1\\Python27\\Lib\\site-packages\\virtualenv_support
C:\Users\User\Desktop>set PIP_USE_WHEEL=1
C:\Users\User\Desktop>set PIP_NO_INDEX=1
C:\Users\User\Desktop>set PIP_PRE=1
C:\Users\User\Desktop>set PYTHONPATH=C:\\Program Files\\Python27\\lib\\site-packages\\virtualenv_support\\setuptools-18.2-py2.py3-none-any.whl;C:\\Program Files\\Python27\\lib\\site-packages\\virtualenv_support\\pip-7.1.2-py2.py3-none-any.whl

C:\Users\User\Desktop>venv\Scripts\python.exe -c "import sys, pip; sys.exit(pip.main(['install', '--ignore-installed', 'setuptools', 'pip', 'wheel']))"
Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Collecting pip
Collecting wheel
Installing collected packages: setuptools, pip, wheel
Successfully installed pip-7.1.2 setuptools-18.2 wheel-0.24.0

C:\Users\User\Desktop>venv\Scripts\activate.bat
(venv) C:\Users\User\Desktop>pip list
pip (7.1.2)
setuptools (18.2)
wheel (0.24.0)

So this approach would make it fixable without modifying pip.

There is already some short path using code in virtualenv. Maybe this can help to improve the details.

@dstufft
Copy link
Member

dstufft commented Jan 19, 2016

should be fixed now with #830

@dstufft dstufft closed this as completed Jan 19, 2016
@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants