Comments (27)
What did cmake say for "Found PythonInterp" and "Found PythonLibs"? It looks like there's a python2 vs 3 problem.
from s2geometry.
I have PYTHONPATH defined and I have only used the default Ubuntu Python installation. Not added anything of my own. How can I check for Found PythonInterp with cmake ? Right now it is saying anything regarding that.
from s2geometry.
Just paste the entire CMake output, there will be lines like "Found PythonInterp: ..." in there.
What do you have $PYTHONPATH set to?
from s2geometry.
PYTHONPATH is set to /usr/lib/python3.6
Whatever I gave you i.e. the cmake output was the result of running cmake . in the build directory.
There was no "Found PythonInterp:" at all in it.
from s2geometry.
Can you:
- Paste the entire CMake output, starting with an empty build/ directory?
- Try again without setting $PYTHONPATH, and tell me if that works.
from s2geometry.
When I unset PYTHONPATH CMake went through without any problems but it is using Python 2.7.15. Is that OK ?
Now I am proceeding to make.
from s2geometry.
Yes, that's ok.
What does python --version
say for you? If it says "Python 2.7.15", then it's probably not a good idea to point PYTHONPATH at a python3 directory.
from s2geometry.
It says 2.7.15rc1. Does this mean I cannot use S2 geometry within Python3.6 scripts ?
from s2geometry.
You might be the first one to try to use s2 with python3.
To try this, you could either:
- Use
update-alternatives
to pointpython
atpython3
. - Add something like
set(Python_ADDITIONAL_VERSIONS 3.6)
toCMakeLists.txt
before thefind_package()
calls.
from s2geometry.
I added it like this in CMakeLists.txt
set(Python_ADDITIONAL_VERSIONS 3.6)
find_package(OpenSSL REQUIRED)
pthreads isn't used directly, but this is still required for std::thread.
find_package(Threads REQUIRED)
find_package(SWIG)
find_package(PythonInterp)
find_package(PythonLibs)
-- The following features have been enabled:
- GFLAGS, allows changing command line flags.
- GLOG, provides logging configurability.
- SHARED_LIBS, builds shared libraries instead of static.
GTEST_ROOT: /usr/src/googletest
File "/usr/lib/python3.6/site.py", line 183
file=sys.stderr)
^
SyntaxError: invalid syntax
CMake Error at src/python/CMakeLists.txt:30 (install):
install TARGETS given no LIBRARY DESTINATION for module target "_pywraps2".
CMake Error at src/python/CMakeLists.txt:31 (install):
install FILES given no DESTINATION!
-- Configuring incomplete, errors occurred!
See also "/home/aswin/S2source/s2geometry/CMakeFiles/CMakeOutput.log".
See also "/home/aswin/S2source/s2geometry/CMakeFiles/CMakeError.log".
Do you want both the log files ?
from s2geometry.
This comment by Al Piszcz suggests that I am not the first to try S2 with Python3 - http://blog.christianperone.com/2015/08/googles-s2-geometry-on-the-sphere-cells-and-hilbert-curve/
import s2sphere as s2
import matplotlib.pyplot as plt
from shapely.geometry import Polygon
import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt
from s2geometry.
Do you want both the log files ?
Yes, please.
This comment by Al Piszcz suggests that I am not the first to try S2 with Python3 - http://blog.christianperone.com/2015/08/googles-s2-geometry-on-the-sphere-cells-and-hilbert-curve/#comment-117962
I'm not sure what he did to make it work with python 3.
Maybe try to put the version numbers in the find_package
instead:
https://stackoverflow.com/a/34580995
find_package(PythonInterp 3.6)
find_package(PythonLibs 3.6)
from s2geometry.
I've been using s2 with Python 3 for months without any modifications.
Arch defaulted to Python3 month ago https://aur.archlinux.org/packages/s2geometry-git
Python 3.7.0 (default, Jul 15 2018, 10:44:58)
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywraps2 as s2
Since it's working I assume this is just an issue with cmake detecting the wrong interpreter, you can probably trick it with -DPYTHON_EXECUTABLE:FILEPATH
from s2geometry.
@akhenakh Thanks. Is CMake finding python2 or 3 for you? If CMake finds python2, will it be possible to use pywraps2
with python3?
from s2geometry.
cmake is finding my default python interpreter which is Python3.
pywraps2 must be compiled with Python3 to be loaded in Python 3.
You can force it with: cmake -DPYTHON_EXECUTABLE=/usr/bin/python3
from s2geometry.
@akhenakh Congratulations ! That worked smoothly. It all works with Python3.6 and I had to install s2sphere but after that it is all a home run. Thanks to @jmr and @akhenakh for their excellent support !
from s2geometry.
I'm confused. s2sphere is a Python reimplementation of a subset of this library. You shouldn't need s2geometry at all if you use s2sphere.
from s2geometry.
I do not know. I was just implementing that example as is given in that external blog as is.
from s2geometry.
s2sphere is an implementation in Python (at the time I've checked it was not relying on the c++ lib and was incompatible in term of results)
You should import import pywraps2 as s2
or the whole thing you compiled is useless
from s2geometry.
Excellent thanks.
from s2geometry.
I have made a docker image s2geometry_docker for s2 compatible with python3 @winash12 , you can download docker image by command docker pull beyouth/s2geometry
@winash12
from s2geometry.
Sorry to reopen this after a year but I am getting a ModuleNotFoundError when I type
import pywraps2 as s2
This is the output of my make install command and I think it is putting pywraps2 in the wrong directory. How can I correct it by mentioning the right -DCMAKE_INSTALL_PREFIX ?
My python3.6 installation directory is here
/usr/local/lib/python3.6/dist-packages and that is where my egg files are located.
My CMAKE build command went like this
cmake ../ _DPYTHON_EXECUTABLE=/usr/bin/python3.6 -DCMAKE_INSTALL_PREFIX=/usr/local/lib/python3.6
Is that incorrect ? Apparently yes because I am still getting a ModuleNotFoundError.
-- Up-to-date: /usr/local/lib/python3.6/include/s2/util/bits/bits.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/coding/coder.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/coding/varint.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/endian/endian.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/btree.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/btree_container.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/btree_map.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/btree_set.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/compact_array.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/container_logging.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/dense_hash_set.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/densehashtable.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/hashtable_common.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/gtl/layout.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/hash/mix.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/math/mathutil.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/math/matrix3x3.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/math/vector.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/math/vector3_hash.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/units/length-units.h -- Up-to-date: /usr/local/lib/python3.6/include/s2/util/units/physical-units.h -- Up-to-date: /usr/local/lib/python3.6/lib/libs2.so -- Up-to-date: /usr/local/lib/python3.6/lib/libs2testing.a -- Up-to-date: /usr/local/lib/python3.6/lib/python3/dist-packages/_pywraps2.so -- Up-to-date: /usr/local/lib/python3.6/lib/python3/dist-packages/pywraps2.py
from s2geometry.
@winash12 I just opened a related issue, #83 - the problem I found was that the default make install prefix put the libs2.so file in the wrong place, but then changing the prefix then puts the pywraps2 module in the wrong place. The workaround I am currently using is to set the make install prefix to just /usr
(which makes libs2.so discoverable) and then adding /usr/local/lib/python3.7/site-packages
to PYTHONPATH environment argument before launching python (which makes the module discoverable). I'm on ubuntu linux w/ the python 3 environment as built by the official docker team. FWIW my functional dockerfile is here https://gist.github.com/jwhiting/05d20afab735355fb0c3972f3f8ad910
from s2geometry.
@jwhiting In my case libs2.so is already present under /usrlocal/lib. So I am not sure how this helps me. I am indeed using Ubuntu Linux 18.04 LTS. So the key question is location of pywraps module. I think I will ask this as a question on Unix Stack Exchange.
from s2geometry.
@jwhiting Wait a moment. Are you saying libs2.so needs to be under /usr and NOT /usr/local/lib ? And that will put pywraps2 at the right location ? I am totally confused now.
from s2geometry.
Script I used to install on debian 9 with python 3.6 managed by conda:
#!/bin/bash
pip install --upgrade pip
sudo apt-get install libgflags-dev libgoogle-glog-dev libgtest-dev libssl-dev -y
sudo apt-get install swig -y
sudo apt-get install cmake -y
mkdir Source
cd Source
git clone https://github.com/google/s2geometry.git
cd s2geometry
mkdir build
cd build
sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/lib/python/ -DGTEST_ROOT=/usr/src/gtest
-DPYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
-DPYTHON_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
-DPYTHON_EXECUTABLE:FILEPATH=which python3
..
sudo make
sudo make install
cp /usr/lib/python/lib/python3.6/site-packages/_pywraps2.so /opt/conda/default/lib/python3.6/site-packages
cp /usr/lib/python/lib/python3.6/site-packages/pywraps2.py /opt/conda/default/lib/python3.6/site-packages
cp /usr/lib/python/lib/libs2.so /opt/conda/default/lib
from s2geometry.
Let's keep the discussion in #83; pwraps2
is compatible with python3.
from s2geometry.
Related Issues (20)
- Is exist way to get initial shapes from s2 index intersection.
- Shouldn't this public function check for null? HOT 4
- Points only optimization doesn't exist for indexing HOT 6
- Move s2geometry to C++14 because abseil minimum is also C++14 HOT 2
- s2 cannot handle more than 2^31 - 1 vertices in polyline/polygon HOT 7
- What is correct way to find point intersects with polygon? HOT 6
- Build fails on PowerPC (ppc32) almost immediately on encoded_s2shape_index.cc HOT 33
- Test errors on PowerPC: 85% tests passed, 16 tests failed out of 110 HOT 8
- Fails to build with abseil-20230125.3: /usr/local/include/absl/base/policy_checks.h:79:2: error: "C++ versions less than C++14 are not supported." HOT 2
- set_target_properties called with incorrect number of arguments HOT 1
- trouble generating cell ids for MultiPollygons
- Is there any method to calculate the ecef coord of the left-up corner of a specified cell id?
- ce8e338 breaks MSVC on Windows HOT 3
- Calculate S2 of polygon with OOM Error in golang HOT 2
- installion s2geometry on windows' issues HOT 18
- After installing s2geometry, CMakeLists.txt failed on "find_package(s2geometry REQUIRED)" HOT 3
- How to boost::serialize S2PointIndex HOT 5
- s2geometry.io has expired?? HOT 2
- problem with S2loop::init HOT 2
- Failed tests with -flto=auto HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s2geometry.