Anthropomorphic criteria are widely adopted for developing socially interactive robots since they can improve human capability to interpret and predict robot motion, with an impact on robot acceptability and human–robot interaction safety. Learning by demonstration approaches based on dynamic movement primitives are a suitable solution for planning the robot motion in human-like fashion and endow robots with generalization capabilities and robustness against perturbation. Objective of this work is to propose a new formulation of the learning by demonstration approach based on dynamic movement primitives (DMPs), called hybrid joint/Cartesian DMPs, for redundant robots with the twofold purpose of avoiding obstacles on the path and obtaining anthropomorphic motion in the joint as well as the task space. The proposed approach, suitable for assistive purposes, was experimentally validated on the anthropomorphic robot arm Kuka Light Weight Robot 4+. Trajectories recorded by an optoelectronic system (i.e. the BTS Smart D) from human demonstrators performing point-to-point reaching and pouring tasks were adopted to teach the robot how to move. A comparative analysis with current methods of learning by demonstration in the literature, i.e. Cartesian DMP and inverse kinematics, was performed. Performance indicators were introduced to (1) assess the robot accuracy of the motion performing, (2) evaluate the level of anthropomorphism of the computed motion, (3) measure the success rate in obstacle avoidance. Moreover, questionnaires were administered to ten human subjects who observed robot motion. The obtained results demonstrated that the proposed approach guarantees anthropomorphic motion of the robot both in the joint and in the task spaces ensuring obstacle avoidance along the robot kinematic chain. In particular, the anthropomorphic robot, while operating with the proposed method, exhibits behaviours in the joint space that are similar to the one recorded during the demonstration and has a level of anthropomorphism rather higher than the one obtained with Cartesian DMP and inverse kinematics (a configuration of the robot joints within the physiological limits is always ensured and the maximum convex hull created between the human and the robot arm is 0.0085 m\(^3\)). In presence of obstacles, an acceptable level of the Cartesian accuracy (\(Position~err<0.005\) m and \(Orientation~err<0.02\) rad) is achieved. The obstacles are avoided with a 100% of success. The questionnaire results showed that the users feel more comfortable and less nervous to interact with a robot that moves in human-like manner.