I'm on Windows 10. Running python 3.7 on a conda virtual env. Using VScode.
I have tried to install swisseph and pyswisseph in every way possible to try and get it to work. I finally got swisseph working and recognized as a module, and I'm using chatgpt to help me write code and learn how to integrate the ephermis into the gpt api. We're going through the steps and it gave me the example code below to use to connect with postman/flask and run the calculate_planet_position function.
The problem is that when I run it, the attribute swe.MERCURY and swe.FLG_SPEED and swe.FLG_SWIEPH and the other attributes are just not being recognized for some reason by my terminal.
I keep getthing the error: _AttributeError: module 'swisseph' has no attribute 'FLGSWIEPH
I dont know what I'm doing wrong. Was hoping to get some help with this.
`
from flask import Flask, request
import swisseph as swe
app = Flask(__name__)
@app.route('/planet_position', methods=['GET'])
def planet_position():
# Get the parameters from the request
date = float(request.args.get('date'))
longitude = float(request.args.get('longitude'))
latitude = float(request.args.get('latitude'))
# Call the calculate_planet_position function to get the planet's position
planet_longitude, planet_latitude = calculate_planet_position(date, longitude, latitude)
# Return the planet's position as a JSON response
return {
'planet_longitude': planet_longitude,
'planet_latitude': planet_latitude
}
def calculate_planet_position(date, longitude, latitude):
"""
Calculates the position of Mercury at a given date, longitude, and latitude.
Args:
date (float): The date and time in Julian days UTC.
longitude (float): The longitude of the observer in degrees.
latitude (float): The latitude of the observer in degrees.
Returns:
tuple: The longitude and latitude of Mercury in degrees.
"""
# Set up the parameters for the calculation
planet = 1 # Use the integer planet number for Mercury
flags = swe.FLG_SWIEPH | swe.FLG_SPEED
position_format = swe.FLG_EQUATORIAL | swe.FLG_SPEED | swe.FLG_TRUEPOS
# Set the observer location
observer_location = [longitude, latitude, 0]
# Calculate the planet's position
planet_position = swe.calc_ut(date, planet, flags)
planet_longitude, planet_latitude, _ = swe.calc_ut(planet_position[0], planet, position_format)
# Convert the planet's position to the observer's location
swe.set_topo(observer_location[0], observer_location[1], observer_location[2])
swe.set_sid_mode(swe.SIDM_LAHIRI)
planet_longitude, planet_latitude, _ = swe.get_topo(planet_longitude)
if __name__ == '__main__':
app.run()
I'm on Windows 10. Running python 3.7 on a conda virtual env. Using VScode.
I have tried to install swisseph and pyswisseph in every way possible to try and get it to work. I finally got swisseph working and recognized as a module, and I'm using chatgpt to help me write code and learn how to integrate the ephermis into the gpt api. We're going through the steps and it gave me the example code below to use to connect with postman/flask and run the calculate_planet_position function.
The problem is that when I run it, the attribute swe.MERCURY and swe.FLG_SPEED and swe.FLG_SWIEPH and the other attributes are just not being recognized for some reason by my terminal.
I keep getthing the error: _AttributeError: module 'swisseph' has no attribute 'FLGSWIEPH
I dont know what I'm doing wrong. Was hoping to get some help with this.
` from flask import Flask, request import swisseph as swe
`