Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pip install psrecord" doesn't work if psutil is not already installed #25

Closed
dhandy2013 opened this issue Feb 26, 2018 · 2 comments
Closed

Comments

@dhandy2013
Copy link

dhandy2013 commented Feb 26, 2018

In the (normal) situation where psutil is not already installed, "pip install psrecord" fails with this error:

$ pip install psrecord
Collecting psrecord
  Downloading psrecord-1.0.tar.gz (55kB)
    100% |████████████████████████████████| 61kB 1.2MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-2BWXB5/psrecord/setup.py", line 34, in <module>
        from psrecord import __version__
      File "psrecord/__init__.py", line 25, in <module>
        from .main import main
      File "psrecord/main.py", line 29, in <module>
        import psutil
    ImportError: No module named psutil

As the stack trace shows, this is because your setup.py file imports the psrecord package in order to get __version__ which is defined in __init__.py. This fails because the psrecord __init__.py also imports psrecord.main, which imports psutil. So it does no good for your setup.py file to say install_requires=['psutil'] because your setup.py script crashes before it reaches that point.

This is a very common pitfall. You need a different method of defining the version in your setup.py file. This webpage documents 7 different ways to do it: https://packaging.python.org/guides/single-sourcing-package-version/

@tonythomas01
Copy link

yes, please add a requirements.txt file!

@astrofrog
Copy link
Owner

@dhandy2013 @tonythomas01 - sorry for the delay in fixing this. I've released psrecord 1.1 which should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants