Unable to install python package with pip, getting

2019-02-28 09:35发布

I am trying to install pyjks. Am running everything in admin command prompt. Initial try to install pyjks resulted in this:

C:\WINDOWS\system32>pip install pyjks
Collecting pyjks
Collecting pycryptodome (from pyjks)
  Using cached https://files.pythonhosted.org/packages/82/bd/bd192c1314bde108a91295fbec02bc20a816330feb10273aa36d885004ab/pycryptodome-3.6.1-cp36-cp36m-win_amd64.whl
Collecting pyasn1-modules (from pyjks)
  Using cached https://files.pythonhosted.org/packages/e9/51/bcd96bf6231d4b2cc5e023c511bee86637ba375c44a6f9d1b4b7ad1ce4b9/pyasn1_modules-0.2.1-py2.py3-none-any.whl
Collecting pyasn1 (from pyjks)
  Using cached https://files.pythonhosted.org/packages/a0/70/2c27740f08e477499ce19eefe05dbcae6f19fdc49e9e82ce4768be0643b9/pyasn1-0.4.3-py2.py3-none-any.whl
Collecting twofish (from pyjks)
  Using cached https://files.pythonhosted.org/packages/82/b4/9eb026a8e62a04512435d3de25c93f7bda51c8b8c7991c1c0be70b5115a6/twofish-0.3.0.tar.gz
Collecting javaobj-py3 (from pyjks)
  Using cached https://files.pythonhosted.org/packages/6a/7d/1979d67bb8f6c5babb8dda0cb79d6d4663ef9a039c193b5adcc787a86285/javaobj_py3-0.2.4-py2.py3-none-any.whl
Installing collected packages: pycryptodome, pyasn1, pyasn1-modules, twofish, javaobj-py3, pyjks
  Running setup.py install for twofish ... error
    Complete output from command "c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-xlk00hde\\twofish\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\crrma\AppData\Local\Temp\pip-record-5jn53157\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying twofish.py -> build\lib.win-amd64-3.6
    running build_ext
    building '_twofish' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-xlk00hde\\twofish\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\crrma\AppData\Local\Temp\pip-record-5jn53157\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\crrma\AppData\Local\Temp\pip-install-xlk00hde\twofish\

I installed Visual C++ 14.0 from here and tried reinstalling. But got same error.

So as suggested in several comments on this page, I upgraded setuptools:

C:\WINDOWS\system32>pip install --upgrade setuptools
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/7f/e1/820d941153923aac1d49d7fc37e17b6e73bfbd2904959fffbad77900cf92/setuptools-39.2.0-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 39.0.1
    Uninstalling setuptools-39.0.1:
      Successfully uninstalled setuptools-39.0.1
Successfully installed setuptools-39.2.0

But still getting the same error. So as suggested on same page, I downloaded tar.gz from here and installed from it:

C:\Users\crrma\Downloads>pip install pyjks-17.1.1.tar.gz
Processing c:\users\crrma\downloads\pyjks-17.1.1.tar.gz
Requirement already satisfied: pyasn1 in c:\program files\python36\lib\site-packages (from pyjks==17.1.1) (0.4.3)
Requirement already satisfied: pyasn1_modules in c:\program files\python36\lib\site-packages (from pyjks==17.1.1) (0.2.1)
Collecting javaobj-py3 (from pyjks==17.1.1)
  Using cached https://files.pythonhosted.org/packages/6a/7d/1979d67bb8f6c5babb8dda0cb79d6d4663ef9a039c193b5adcc787a86285/javaobj_py3-0.2.4-py2.py3-none-any.whl
Requirement already satisfied: pycryptodome in c:\program files\python36\lib\site-packages (from pyjks==17.1.1) (3.6.1)
Collecting twofish (from pyjks==17.1.1)
  Using cached https://files.pythonhosted.org/packages/82/b4/9eb026a8e62a04512435d3de25c93f7bda51c8b8c7991c1c0be70b5115a6/twofish-0.3.0.tar.gz
Installing collected packages: javaobj-py3, twofish, pyjks
  Running setup.py install for twofish ... error
    Complete output from command "c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-c3n_0udc\\twofish\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\crrma\AppData\Local\Temp\pip-record-tpgigq69\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying twofish.py -> build\lib.win-amd64-3.6
    running build_ext
    building '_twofish' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-c3n_0udc\\twofish\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\crrma\AppData\Local\Temp\pip-record-tpgigq69\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\crrma\AppData\Local\Temp\pip-install-c3n_0udc\twofish\

But its simply not getting installed. Whats going wrong here?

I am running latest version of python:

C:\>python
Python 3.6.6rc1 (v3.6.6rc1:1015e38be4, Jun 12 2018, 08:38:06) [MSC v.1900 64 bit (AMD64)] on win32

标签: python pip
1条回答
何必那么认真
2楼-- · 2019-02-28 10:36

I was not able to fix this up. (I tried by installing this, but it didnt work. It seems that what I installed is runtime but not the compiler and we need to install Visual Studio for installing compiler. I was not feeling great to run big setup of the Visual Studio just to install single python package.) Instead I resorted to setting up cygwin (which is small compared to Visual Studio and was already installed on my machine). I tried running pip3 install pyjks on cygwin terminal, but now it gave error saying it did not find gcc. It seems that somehow some dependencies of pyjks needs to be compiled by C compiler. So I installed gcc in cygwin. However it was also failing. So I installed gcc using apt-cyg. All the steps are explained below.

  1. Install cygwin
  2. In cygwin setup, select python3, pip3 and gcc-g++ packages in package selection window:

    • python3-devel: Py3K language interpreter
    • python3-pip: Python package installation tool
    • gcc-core: GNU Compiler Collection (C,OpenMP)
    • gcc-g++: GNU Compiler Collection (C++)

    enter image description here

  3. If you forget to select them or if you have cygwin already installed and want to install these additional packages, then you can rerun the cygwin setup (that is, path-to-cygwin\cygwin\setup\setup-x86_64.exe) and select above packages.
  4. I was not able to install gcc by above approach. It was giving me following error: enter image description here
    So I tried installing it using apt-cyg. You can find steps to install apt-cyg in this answer. Once apt-cyg is accessible from cyg-win terminal (that is, path-to-cygwin\cygwin\setup\Cygwin.bat), you can run following command to install gcc

    apt-cyg install gcc-g++
    
  5. Once gcc is installed, you can install pyjks using pip (it will not give any error saying C compiler not found):

    pip3 install pyjks
    

I was even able to point python inside cygwin (that is, path-to-cygwin\cygwin\bin\python3) as python interpreter for eclipse PyDev module. This also allowed me to use os.fork() in python, since windows python's os module does not contain fork().

查看更多
登录 后发表回答