\pyrcc_main.py: File does not exist 'resources.qrc'

import sys, os, tempfile
import sip
sip.setapi('QString', 2)
from PyQt4 import QtCore
# from PyQt5 import QtCore

respath = os.path.abspath(sys.argv[1])
dirpath = os.path.dirname(respath)
sys.path.insert(0, dirpath)

import resources_rc

tmpdir = tempfile.mkdtemp(prefix='qrc_', dir=dirpath)

it = QtCore.QDirIterator(':', QtCore.QDirIterator.Subdirectories)

files = []

while it.hasNext():
    uri = it.next()
    path = uri.lstrip(':/')
    if path.startswith('qt-project.org'):
        continue
    tmp = os.path.join(tmpdir, path)
    if it.fileInfo().isDir():
        try:
            os.makedirs(tmp)
        except OSError:
            pass
    else:
        res = QtCore.QFile(uri)
        res.open(QtCore.QIODevice.ReadOnly)
        with open(tmp, 'wb') as stream:
            stream.write(bytes(res.readAll()))
        res.close()
        files.append('    <file>%s</file>\n' % path.lstrip(':/'))

with open(os.path.join(tmpdir, 'resources.qrc'), 'w') as stream:
    stream.write('<!DOCTYPE RCC><RCC version="1.0">\n')
    stream.write('<qresource>\n%s</qresource>\n' % ''.join(files))

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source