Method for correcting the position and deviation of a syringe needle in a machine for automatically preparing intravenous medication, comprising an automatic actuator, said automatic actuator being a robotic arm, together with a control system, in which are placed the syringe and a one-dimensional position sensor comprising a measuring plane, the correction method comprising the following steps: - positioning the syringe, by the automatic actuator, in a first measuring position in which a first point of the needle interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a first position coordinate of the first point of the needle, - positioning the syringe, by the automatic actuator, in a second measuring position (P1-13) in which a second point of the needle, located a predetermined distance away from the first point, interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a first position coordinate of the second point of the needle, - rotating the syringe, by the automatic actuator, by 90° about the longitudinal axis thereof, - positioning the 90° rotated syringe, by the automatic actuator, in a third measuring position in which the first point of the needle interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a second position coordinate of the first point of the needle, - positioning the 90° rotated syringe, by the automatic actuator, in a fourth measuring position (P2-13) in which the second point of the needle interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a second position coordinate of the second point of the needle, - moving the position sensor away, by the automatic actuator, - determining, by the control system of the automatic actuator, the position and deviation error of the needle relative to a reference needle using the position coordinates obtained in the previous phases, - correcting the position and deviation error of the needle, by the control system of the automatic actuator, - after correcting the position and deviation error of the needle, said robotic arm adopts a position so that the needle punctures a container perpendicularly, irrespective of its deviation. - positioning the syringe, by the automatic actuator, in a first measuring position in which a first point of the needle interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a first position coordinate of the first point of the needle, - positioning the syringe, by the automatic actuator, in a second measuring position (P1-13) in which a second point of the needle, located a predetermined distance away from the first point, interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a first position coordinate of the second point of the needle, - rotating the syringe, by the automatic actuator, by 90° about the longitudinal axis thereof, - positioning the 90° rotated syringe, by the automatic actuator, in a third measuring position in which the first point of the needle interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a second position coordinate of the first point of the needle, - positioning the 90° rotated syringe, by the automatic actuator, in a fourth measuring position (P2-13) in which the second point of the needle interferes with the measuring plane of the position sensor, - obtaining, by the position sensor, a second position coordinate of the second point of the needle, - moving the position sensor away, by the automatic actuator, - determining, by the control system of the automatic actuator, the position and deviation error of the needle relative to a reference needle using the position coordinates obtained in the previous phases, - correcting the position and deviation error of the needle, by the control system of the automatic actuator, - after correcting the position and deviation error of the needle, said robotic arm adopts a position so that the needle punctures a container perpendicularly, irrespective of its deviation.