We propose a method and algorithm for computing the weighted Moore–Penrose inverse of one-variable rational matrices. Continuing this idea, we develop an algorithm for computing the weighted Moore–Penrose inverse of one-variable polynomial matrix. These methods and algorithms are generalizations of the method for computing the weighted Moore–Penrose inverse for constant matrices, originated in Wang and Chen [G.R. Wang, Y.L. Chen, A recursive algorithm for computing the weighted Moore–Penrose inverse A MN † , J. Comput. Math. 4 (1986) 74–85], and the partitioning method for computing the Moore–Penrose inverse of rational and polynomial matrices introduced in Stanimirović and Tasić [P.S. Stanimirović, M.B. Tasić, Partitioning method for rational and polynomial matrices, Appl. Math. Comput. 155 (2004) 137–163]. Algorithms are implemented in the symbolic computational package MATHEMATICA.