question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rpmvenv failing and complaining about 'time' module not existing.

See original GitHub issue

Hello,

When I run rpmvenv to package my python library I get a wierd error saying it was not possible to import the library ‘time’.

Although if I create a virtual env myself and import time, it works just fine.

This is for CentOS Linux 7 (Core)

The json file, for now, is pretty basic (almost equal to the one in the example):

{
    "extensions": {
        "enabled": [
            "python_venv",
            "blocks"
        ]
    },
    "core": {
        "group": "Application/System",
        "license": "MIT",
        "name": "myRPM",
        "summary": "short package summary",
        "version": "1.0"
    },
    "python_venv": {
        "name": "venv",
        "path": "/usr/share/myPathRPM/"
    },
    "blocks": {
        "desc": [
            "some long package description",
            "each array element is a new line"
        ]
    }
}

And the output is:

[user@localhost ~]$ rpmvenv build.json 
There was an error generating the RPM.
The exit code was: 1.
The rpmbuild command was: rpmbuild -ba --define='_topdir /tmp/rpmvenvgduuy3rh' /tmp/rpmvenvgduuy3rh/SOURCES/package.spec.
The stderr was: b'+ umask 022
+ cd /tmp/rpmvenvgduuy3rh/BUILD
+ rm -rf \'/tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64/*\'
+ mkdir -p /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64//usr/share/myPathRPM//venv
+ exit 0
+ umask 022
+ cd /tmp/rpmvenvgduuy3rh/BUILD
+ \'[\' /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64 \'!=\' / \']\'
+ rm -rf /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64
++ dirname /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64
+ mkdir -p /tmp/rpmvenvgduuy3rh/BUILDROOT
+ mkdir /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64
+ virtualenv --always-copy /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64//usr/share/myPathRPM//venv
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.4/site-packages/virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "/usr/lib/python3.4/site-packages/virtualenv.py", line 945, in create_environment
    download=download,
  File "/usr/lib/python3.4/site-packages/virtualenv.py", line 901, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/lib/python3.4/site-packages/virtualenv.py", line 797, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /tmp/rpmvenvgduuy3rh...M/venv/bin/python3.4 - setuptools pip wheel failed with error code 1
error: Bad exit status from /var/tmp/rpm-tmp.hbCgy8 (%install)
    Bad exit status from /var/tmp/rpm-tmp.hbCgy8 (%install)
'.
The stdout was: b'Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.tU518l
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.hbCgy8
Using base prefix \'/usr\'
Cannot find file lib (bad symlink)
New python executable in /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64/usr/share/myPathRPM/venv/bin/python3.4
Also creating executable in /tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64/usr/share/myPathRPM/venv/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /tmp/rpmvenvgduuy3rh...M/venv/bin/python3.4 - setuptools pip wheel:
  Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64/usr/share/myPathRPM/venv/lib64/python3.4/tempfile.py", line 34, in <module>
    import shutil as _shutil
  File "/tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64/usr/share/myPathRPM/venv/lib64/python3.4/shutil.py", line 14, in <module>
    import tarfile
  File "/tmp/rpmvenvgduuy3rh/BUILDROOT/myRPM-1.0-1.x86_64/usr/share/myPathRPM/venv/lib64/python3.4/tarfile.py", line 47, in <module>
    import time
ImportError: No module named \'time\'
----------------------------------------
...Installing setuptools, pip, wheel...done.


RPM build errors:
'.

Any help please?

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinconwaycommented, May 19, 2017

Does the same error occur if you manually run virtualenv with the same --always-copy flag that rpmvenv uses? I believe this may actually be a bug in the recent release of virtualenv. Reference: https://github.com/pypa/virtualenv/issues/565

0reactions
kevinconwaycommented, May 22, 2017

I’m glad we could figure it out! Let me know if you have any more trouble.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Can't install time module
I'm working in PyCharm, but what really doesn't make sense is that I can import time in the Python Console but not in...
Read more >
rpmvenv
The issue manifests during the creation of the virtualenv and appears as something like ImportError: No module named 'time' or other error messages...
Read more >
How We Deploy Python Code
Fast, zero downtime deployments, multiple times a day, and if anything failed, the build simply didn't go out and I'd try again after...
Read more >
2022-March.txt - Python mailing list
Time, as humans have defined it with timezones, leap years, ... If you've completed it, why not show us your Python code so...
Read more >
Thursday, 2015-07-30 - IRC channels and meetings
mordred, I'm happy to resync this for you one more time - but I'm not happy to ... think the log copying really...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found