Skip to content

Instantly share code, notes, and snippets.

@ifmihai
Last active December 30, 2020 14:31
Show Gist options
  • Save ifmihai/9fae789ef1ed2fcbedc5ace7cb1d3797 to your computer and use it in GitHub Desktop.
Save ifmihai/9fae789ef1ed2fcbedc5ace7cb1d3797 to your computer and use it in GitHub Desktop.
How to build and use pyswisseph python package on windows
On windows, you cannot install directly the pyswisseph python package.
Pyswisseph, is the python extension to AstroDienst Swiss Ephemeris library.
https://pypi.org/project/pyswisseph/
So, after contacting the creator of the this python package,
and after many tries,
i came up with this workflow, to build the pyd DLL yourself.
I succeeded with python 2.7 32bit, and also python 3.7 64bit
0.
install cmake
(be sure to check that option, to add cmake to windows PATH)
(also be sure it is added at the end of the PATH variable, but by default it's added the last anyway)
1.
get pyswisseph from github (it has the good CMakeLists )
unzip it somewhere
2.
create (add) a new folder in there, name it: build
3.
open a cmd terminal window inside that folder build
4.
write: cmake-gui.exe ..
(don't omit those 2 dots, then hit enter)
5.
paths for build and sources should appear there, correctly
6.
click on 'Configure', choose visual studio compiler
7.
now there are red fields in there, that's fine
change the path for swiss ephemeris files: in my case it's "c:\\sweph\\ephe" (without quotes, mind you)
check the python version, be sure it's what you have
8.
click configure once again
red fields should go at this point
9.
click generate button again
everything should be without errors at this point
10.
open the pyswisseph.sln file with visual studio
put IDE in release mode (not debug mode) (that selectbox with debug/release in it)
(in debug mode it will not find some debug libs, because of anaconda)
11.
build the solution
12.
the result is the swisseph.pyd file, which is found in Release folder
this file, copy it, or move it inside your Python path
in my case, this is: c:\users\username\miniconda3\DLLs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment