if pdflatex should freate figures using pgf and tikz an additional parameter needs to be send to pdflatex. eg in texworks: go to “edit”–>”preferences”->”typesetting” and find pfglatex. Add the parameter “-shell-escape” and move it so its the first argument.