简体   繁体   中英

Failure to install python package (osmium)

I am trying to install a python package called osmium into a virtual environment that I created with venv. With the virtual environment activated and from the Scripts directory of the virtual environment, calling

pip install osmium

fails (error message below). I am using pycharm as an IDE. Attempting to install osmium via the IDE also fails.

Interestingly, I have a colleague with the identical computer and identical versions of python and pycharm who succeeded in installing osmium. He relied directly on the virtual environment created by pycharm (which, I think, uses virtualenv instead of venv), never using venv and had no problem.

I even went as far as reinstalling both python and pycharm to no avail. I wonder what's going on here. Why is this happening in the first place? And what is causing the failure even after reinstalling (do some traces of python and pycharm remain?)

The error message is:

D:\virtual_envs\test_env\Scripts>activate
(test_env) D:\virtual_envs\test_env\Scripts>pip install osmium
Collecting osmium
  Using cached https://files.pythonhosted.org/packages/65/ec/41bc12a33bc9feab921e5e21999fe30882288f2f4f8d8a4536dcd03e2c0b/osmium-2.15.2.tar.gz
Installing collected packages: osmium
  Running setup.py install for osmium ... error
    Complete output from command d:\virtual_envs\test_env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium\\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\J84120~1\AppData\Local\Temp\pip-record-torhb0ih\install-record.txt --single-version-externally-managed --compile --install-headers d:\virtual_envs\test_env\include\site\python3.7\osmium:
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\osmium
copying src\osmium\version.py -> build\lib.win32-3.7\osmium
copying src\osmium\__init__.py -> build\lib.win32-3.7\osmium
creating build\lib.win32-3.7\osmium\osm
copying src\osmium/osm\mutable.py -> build\lib.win32-3.7\osmium/osm
copying src\osmium/osm\__init__.py -> build\lib.win32-3.7\osmium/osm
creating build\lib.win32-3.7\osmium\replication
copying src\osmium/replication\server.py -> build\lib.win32-3.7\osmium/replication
copying src\osmium/replication\utils.py -> build\lib.win32-3.7\osmium/replication
copying src\osmium/replication\__init__.py -> build\lib.win32-3.7\osmium/replication
running build_ext
-- Building for: Visual Studio 14 2015
-- Selecting Windows SDK version  to target Windows 10.0.17134.
-- The C compiler identification is MSVC 19.0.24210.0
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found Protozero: C:/Users/J84120841/AppData/Local/Temp/pip-install-3_44nlf3/osmium/contrib/protozero/include (found suitable version "1.6.7", minimum required is "1.5.1")
CMake Warning at cmake/FindOsmium.cmake:127 (message):
  Osmium: Can not find some libraries for PBF input/output, please install
  them or configure the paths.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


-- Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
CMake Warning at cmake/FindOsmium.cmake:153 (message):
  Osmium: Can not find some libraries for XML input/output, please install
  them or configure the paths.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


CMake Error at D:/virtual_envs/test_env/Lib/site-packages/cmake/data/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Osmium (missing: ZLIB_FOUND EXPAT_FOUND BZIP2_FOUND) (found
  suitable version "2.15.1", minimum required is "2.14")
Call Stack (most recent call first):
  D:/virtual_envs/test_env/Lib/site-packages/cmake/data/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindOsmium.cmake:278 (find_package_handle_standard_args)
  CMakeLists.txt:6 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/J84120841/AppData/Local/Temp/pip-install-3_44nlf3/osmium/build/temp.win32-3.7/Release/CMakeFiles/CMakeOutput.log".
See also "C:/Users/J84120841/AppData/Local/Temp/pip-install-3_44nlf3/osmium/build/temp.win32-3.7/Release/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\J84120~1\AppData\Local\Temp\pip-install-3_44nlf3\osmium\setup.py", line 150, in <module>
    zip_safe=False,
  File "d:\virtual_envs\test_env\lib\site-packages\setuptools\__init__.py", line 143, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "d:\virtual_envs\test_env\lib\site-packages\setuptools\command\install.py", line 61, in run
    return orig.install.run(self)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\command\install.py", line 545, in run
    self.run_command('build')
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\J84120~1\AppData\Local\Temp\pip-install-3_44nlf3\osmium\setup.py", line 67, in run
    self.build_extension(ext)
  File "C:\Users\J84120~1\AppData\Local\Temp\pip-install-3_44nlf3\osmium\setup.py", line 110, in build_extension
    subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
  File "C:\Users\J84120841\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\J84120~1

\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium\\build\\lib.win32-3.7', '-DPYTHON_EXECUTABLE=d:\\virtual_envs\\test_env\\scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium\\build\\lib.win32-3.7', '-DOSMIUM_INCLUDE_DIR=C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium/contrib/libosmium/include', '-DPROTOZERO_INCLUDE_DIR=C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium/contrib/protozero/include', '-DPYBIND11_PREFIX=C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium/contrib/pybind11']' returned non-zero exit status 1.

    ----------------------------------------
Command "d:\virtual_envs\test_env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\J84120~1\\AppData\\Local\\Temp\\pip-install-3_44nlf3\\osmium\\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\J84120~1\AppData\Local\Temp\pip-record-torhb0ih\install-record.txt --single-version-externally-managed --compile --install-headers d:\virtual_envs\test_env\include\site\python3.7\osmium" failed with error code 1 in C:\Users\J84120~1\AppData\Local\Temp\pip-install-3_44nlf3\osmium\
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(test_env) D:\virtual_envs\test_env\Scripts>

The problem lies in OS dependencies for development packages. From the documentation , you can get library names that you also see in your error message

    sudo apt-get install build-essential cmake libboost-dev \
                        libexpat1-dev zlib1g-dev libbz2-dev

That command is for Debian-based distributions. So you have to find MS Windows versions

Bzip2

    http://gnuwin32.sourceforge.net/packages/bzip2.htm

Zlib

    http://gnuwin32.sourceforge.net/packages/zlib.htm

expat as NuGet package

    https://www.nuget.org/api/v2/package/expat.v141/2.2.6

There is an option from ZeroC Ice for VisualStudio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM