Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sebalvarez

macrumors regular
Original poster
Apr 15, 2022
147
60
I'm trying to run the app Asitop, which is used by a lot of Mac reviewers to show power usage and other info about the Mac, but no matter what I do, this is all I keep getting:

myusername@Mymachinename ~ % sudo asitop

Password:

sudo: asitop: command not found

myusername@Mymachinename ~ % asitop

zsh: command not found: asitop

I have followed all the steps and installed everything that is required, like pip, ptyhon, etc. I added the Asitop path to the path environment file. Hell, I even navigated to the folder it is installed in, and tried launching it from there, and nothing.

Any suggestions?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,996
8,887
A sea of green
After you've navigated to the folder it's installed in, try this command, then copy and paste the exact output here:
Code:
ls -leO@ .

If that command gives an error message rather than a listing, then try just this:
Code:
ls -l .

Exactly what command did you type when you tried launching it from its install folder? Details are important with command-lines. For example, simply cding to the install folder and typing asitop usually won't work, because the current working dir (known as ".") isn't usually in the PATh variable. This is because having "." in PATH has security ramifications.
 

sebalvarez

macrumors regular
Original poster
Apr 15, 2022
147
60
This is the output from the first command, with my actual user name replaced:

total 64
-rw-r--r-- 1 myusername staff - 0 Jun 15 17:58 __init__.py
-rw-r--r--@ 1 myusername staff - 13556 Jun 15 17:58 asitop.py
com.apple.lastuseddate#PS 16
-rw-r--r-- 1 myusername staff - 6568 Jun 15 17:58 parsers.py
-rw-r--r-- 1 myusername staff - 6212 Jun 15 17:58 utils.py

The way I tried to run it was the way it said in the asitop github page, "sudo asitop" without quotes.

After that, I even tried and installed asitop using homebrew, but same result.
 

JimmyjamesEU

Suspended
Jun 28, 2018
397
426
This is the output from the first command, with my actual user name replaced:

total 64
-rw-r--r-- 1 myusername staff - 0 Jun 15 17:58 __init__.py
-rw-r--r--@ 1 myusername staff - 13556 Jun 15 17:58 asitop.py
com.apple.lastuseddate#PS 16
-rw-r--r-- 1 myusername staff - 6568 Jun 15 17:58 parsers.py
-rw-r--r-- 1 myusername staff - 6212 Jun 15 17:58 utils.py

The way I tried to run it was the way it said in the asitop github page, "sudo asitop" without quotes.

After that, I even tried and installed asitop using homebrew, but same result.
Try navigating to that folder and then type “sudo ./asitop.py”
 
  • Like
Reactions: chown33

chown33

Moderator
Staff member
Aug 9, 2009
10,996
8,887
A sea of green
Try navigating to that folder and then type “sudo ./asitop.py”
That's worth a shot, but I think it will fail, probably with a permission error.

The file "asitop.py" lacks the 'x' permission. That strongly suggests that the shell will refuse to execute it.

A cmd-line including the 'python' cmd might be more likely to work, but I don't use Python at all, so have nothing concrete or tested to suggest.


Since no link was provided, I looked here:

I don't see any component in the provided source with the exact name 'asitop'. So as given at github.com, there isn't anything with the correct name for the cmd to work as given.

The only thing that makes sense to me is that the 'pip' tool mentioned in the "Installation and Usage" section is absolutely required, and does some magic to create an executable or script with the exact name 'asitop'.

The examples of usage clearly show it being run without 'sudo', and the '-h' option lists out help. That strongly suggests to me that the usage examples are written for a command named exactly 'asitop', located in some dir listed in one's PATH var.

Or I could have missed something.


To the OP:
Did you install asitop using 'pip' as the instructions describe?
 

JimmyjamesEU

Suspended
Jun 28, 2018
397
426
That's worth a shot, but I think it will fail, probably with a permission error.

The file "asitop.py" lacks the 'x' permission. That strongly suggests that the shell will refuse to execute it.

A cmd-line including the 'python' cmd might be more likely to work, but I don't use Python at all, so have nothing concrete or tested to suggest.


Since no link was provided, I looked here:

I don't see any component in the provided source with the exact name 'asitop'. So as given at github.com, there isn't anything with the correct name for the cmd to work as given.

The only thing that makes sense to me is that the 'pip' tool mentioned in the "Installation and Usage" section is absolutely required, and does some magic to create an executable or script with the exact name 'asitop'.

The examples of usage clearly show it being run without 'sudo', and the '-h' option lists out help. That strongly suggests to me that the usage examples are written for a command named exactly 'asitop', located in some dir listed in one's PATH var.

Or I could have missed something.


To the OP:
Did you install asitop using 'pip' as the instructions describe?
So…”sudo python3 ./asitop.py”…?
 

jdb8167

macrumors 601
Nov 17, 2008
4,859
4,599
This is the output from the first command, with my actual user name replaced:

total 64
-rw-r--r-- 1 myusername staff - 0 Jun 15 17:58 __init__.py
-rw-r--r--@ 1 myusername staff - 13556 Jun 15 17:58 asitop.py
com.apple.lastuseddate#PS 16
-rw-r--r-- 1 myusername staff - 6568 Jun 15 17:58 parsers.py
-rw-r--r-- 1 myusername staff - 6212 Jun 15 17:58 utils.py

The way I tried to run it was the way it said in the asitop github page, "sudo asitop" without quotes.

After that, I even tried and installed asitop using homebrew, but same result.
Run:
which -a asitop

If that shows:
/opt/homebrew/bin/asitop
Then you installed it correctly with brew. Make sure that file is executable:
-rwxr-xr-x 1 jdb8167 admin 238 May 12 10:16 /opt/homebrew/bin/asitop
The first x in -rwxr-xr-x is necessary for it to execute. In my case, anyone can execute it.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,996
8,887
A sea of green
So…”sudo python3 ./asitop.py”…?
Maybe.

The thing is, we don't know what might be in the actual executable whose name is 'asitop'.

When I write shell scripts, for example, I might look for env vars, or set some up, before continuing with whatever other sub-tools get run.
 

jdb8167

macrumors 601
Nov 17, 2008
4,859
4,599
Maybe.

The thing is, we don't know what might be in the actual executable whose name is 'asitop'.

When I write shell scripts, for example, I might look for env vars, or set some up, before continuing with whatever other sub-tools get run.
The version that I installed with pip3 (downloaded with Python@3.9 with brew) has the following in /opt/homebrew/bin/asitop:
#!/opt/homebrew/opt/python@3.9/bin/python3.9 # -*- coding: utf-8 -*- import re import sys from asitop.asitop import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main())
 

sebalvarez

macrumors regular
Original poster
Apr 15, 2022
147
60
First of all, thank you for all your replies. None of the suggestions worked, but I really appreciate nevertheless. Here's the funny thing: I'm an old fart and my memory is going downhill, so I couldn't even remember the path to it from like, yesterday. I kind of remembered it was in the user library, so I went there and did a search for asitop, which gave me this:

1655519603508.png


So I double click on the Unix exec file and voilá! Asitop started, after asking me for the admin password. So I guess I just need to put a shortcut to that file on the desktop and that's it!
 

sebalvarez

macrumors regular
Original poster
Apr 15, 2022
147
60
OK I think I spoke too soon. That worked only once. After I closed it, when I tried to open it again, I got this (my real user name and machine name replaced obviously):
Code:
Last login: Fri Jun 17 22:43:21 on ttys000
/Users/myusername/Library/Python/3.8/bin/asitop ; exit;
Adding directories to PATH:
PATH += /Users/myusername/emsdk
PATH += /Users/myusername/emsdk/upstream/emscripten
PATH += /Users/myusername/emsdk/node/14.18.2_64bit/bin

Setting environment variables:
PATH = /Users/myusername/emsdk:/Users/myusername/emsdk/upstream/emscripten:/Users/myusername/emsdk/node/14.18.2_64bit/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
EMSDK = /Users/myusername/emsdk
EM_CONFIG = /Users/myusername/emsdk/.emscripten
EMSDK_NODE = /Users/myusername/emsdk/node/14.18.2_64bit/bin/node
EMSDK_PYTHON = /Users/myusername/emsdk/python/3.9.2_64bit/bin/python3
SSL_CERT_FILE = /Users/myusername/emsdk/python/3.9.2_64bit/lib/python3.9/site-packages/certifi/cacert.pem
Setting environment variables:
myusername@My-Mac-Studio ~ % /Users/myusername/Library/Python/3.8/bin/asitop ; exit;

ASITOP - Performance monitoring CLI tool for Apple Silicon
You can update ASITOP by running `pip install asitop --upgrade`
Get help at `https://github.com/tlkh/asitop`
P.S. You are recommended to run ASITOP with `sudo asitop`


[1/3] Loading ASITOP


[2/3] Starting powermetrics process

Traceback (most recent call last):
  File "/Users/myusername/Library/Python/3.8/bin/asitop", line 8, in <module>
    sys.exit(main())
  File "/Users/myusername/Library/Python/3.8/lib/python/site-packages/asitop/asitop.py", line 109, in main
    powermetrics_process = run_powermetrics_process(timecode,
  File "/Users/myusername/Library/Python/3.8/lib/python/site-packages/asitop/utils.py", line 49, in run_powermetrics_process
    os.remove(tmpf)
PermissionError: [Errno 13] Permission denied: '/tmp/asitop_powermetrics1655519400'

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

I copied and pasted the whole text in the terminal window so maybe one of you can tell me what's wrong. About a week ago I tried to compile Unreal Engine 4.24 from Github, following every step, and it didn't work, there were errors on pretty much everything I did because that probably worked 3 years ago when they posted the instructions.

So all the EMSDK stuff you see there was part of the installation of one of the many items you have to install to compile that engine, and some day when I have more time I'm going to find how to uninstall it. I don't know if it's causing any conflict with asitop. I just find it really weird that I was able to launch asitop just fine double clicking that Unix file and now it gives me this error. Actually I went to that file that says permission denied, and I gave "Read & Write" permissions to the three users that were there, but still no luck.

Any ideas?
 

sebalvarez

macrumors regular
Original poster
Apr 15, 2022
147
60
So here's the weird thing: if I delete that file that it creates when I launch it, then the next time it opens fine. But I have to delete that file (/tmp/asitop_powermetrics1655524086) to be able to run it. That doesn't sound like it should be that way.
 

altaic

macrumors 6502a
Jan 26, 2004
711
484
You just need to add /Users/myusername/Library/Python/3.8/bin to your shell’s PATH environment variable. For instance, if you use bash, edit .bash_profile in your home directory and add a line at the end:
Code:
export PATH="/Users/myusername/Library/Python/3.8/bin:$PATH"

Then reopen a Terminal session. Now you can just run sudo asitop from Terminal.

If your shell is something else (e.g. csh, zsh, etc.), the steps would be similar.
 
Last edited:
  • Like
Reactions: techpr

NHerby

macrumors newbie
Jul 21, 2022
1
0
I jump on this thread as I have the very same issue.
On my side, I had to install pip first, then "pip3 install asitop" but after:
Code:
sudo asitop                                      
Password:
sudo: asitop: command not found
And if I try "sudo python3 /Users/myusername/Library/Python/3.8/lib/python/site-packages/asitop/asitop.py", it gives:
Code:
Traceback (most recent call last):
  File "/Users/herve/Library/Python/3.8/lib/python/site-packages/asitop/asitop.py", line 6, in <module>
    from .utils import *
ImportError: attempted relative import with no known parent package
 

sebalvarez

macrumors regular
Original poster
Apr 15, 2022
147
60
I jump on this thread as I have the very same issue.
I forgot to post about this for weeks, but what worked for me was that I made an alias to Asitop on the desktop, so I just launch it from there. It asks me for my admin password, and then it opens fine.
 

danielktdoranie

macrumors member
Jul 28, 2021
46
26
I got it to work! ...and without Homebrew (that I don't like!) too!

This comes down to Python not being in your path, like altaic said

Warning asitop ONLY runs on macOS Monterey! Make sure Monterey is up-to-date on 12.6

  1. Open Terminal.app
  2. Type
    Code:
    python3 --version
    (you're looking for Python 3.9.6)
  3. Download pip by running the following command:
    Code:
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  4. Install the downloaded package by running:
    Code:
    python3 get-pip.py
  5. You will get a warning in yellow stating something to the effect of it's not in "PATH"
  6. Run this command:
    Code:
    nano .zprofile
    (assuming you are using the default macOS Monterey Zsh shell)
  7. While editing .zprofile in the Nano editor type:
    Code:
    # Set PATH
    on the first line and
    Code:
    export PATH="/Users/WhateverYourUsername/Library/Python/3.9/bin:$PATH"
    on the second line... it should look similar to mine here:
    Screenshot 2022-10-11 at 13.12.44.png
  8. Press control and the letter x on your keyboard. You will be asked to save the file. Answer with:
    Code:
    Y
  9. You will be asked for a file name, just press enter.
  10. Run this command:
    Code:
    nano .zprofile
    again to open the file and make sure your edits were saved. If not, you messed up and go back to step 6!
  11. Exit the Terminal app. Make sure you quit the Terminal app, not just close the terminal window! (restart the Mac if you like!)
  12. At the Zsh shell prompt type:
    Code:
    pip3 install asitop
    this will install asitop
  13. Again, exit the Terminal app. Make sure you quit the Terminal app!
  14. Open Terminal.app and type
    Code:
    sudo asitop
    and press the enter key. You will be prompted for you macOS system password, enter it. Now it should run! Press the control and the c keys to exit asitop.
FYI my computer is a MacBook Air (M1, 2020) w/ 16GB RAM running macOS Monterey 12.6. My package manager is pkgsrc (not that it matters as Python comes with macOS) To install pkgsrc on your Mac: https://pkgsrc.joyent.com/install-on-macos/ (again, NOT NECESSARY for asitop, just a really good package manager I like)
 

Attachments

  • Screenshot 2022-10-11 at 13.40.10.png
    Screenshot 2022-10-11 at 13.40.10.png
    335 KB · Views: 181
Last edited:

ArkSingularity

macrumors 6502a
Mar 5, 2022
928
1,130
I can't help much with AsiTop, but MX Power Gadget is a similar tool that has the same functionality. It is basically an Intel-Power-Gadget clone for Apple-Silicon.

It sounds like @danielktdoranie 's suggestions are easy to follow though, I'll try to install it later this afternoon and see what happens.
 

mike.coulter

macrumors regular
Jun 10, 2008
224
117
I got it to work! ...and without Homebrew (that I don't like!) too!

This comes down to Python not being in your path, like altaic said

Warning asitop ONLY runs on macOS Monterey! Make sure Monterey is up-to-date on 12.6

  1. Open Terminal.app
  2. Type
    Code:
    python3 --version
    (you're looking for Python 3.9.6)
  3. Download pip by running the following command:
    Code:
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  4. Install the downloaded package by running:
    Code:
    python3 get-pip.py
  5. You will get a warning in yellow stating something to the effect of it's not in "PATH"
  6. Run this command:
    Code:
    nano .zprofile
    (assuming you are using the default macOS Monterey Zsh shell)
  7. While editing .zprofile in the Nano editor type:
    Code:
    # Set PATH
    on the first line and
    Code:
    export PATH="/Users/WhateverYourUsername/Library/Python/3.9/bin:$PATH"
    on the second line... it should look similar to mine here: View attachment 2092714
  8. Press control and the letter x on your keyboard. You will be asked to save the file. Answer with:
    Code:
    Y
  9. You will be asked for a file name, just press enter.
  10. Run this command:
    Code:
    nano .zprofile
    again to open the file and make sure your edits were saved. If not, you messed up and go back to step 6!
  11. Exit the Terminal app. Make sure you quit the Terminal app, not just close the terminal window! (restart the Mac if you like!)
  12. At the Zsh shell prompt type:
    Code:
    pip3 install asitop
    this will install asitop
  13. Again, exit the Terminal app. Make sure you quit the Terminal app!
  14. Open Terminal.app and type
    Code:
    sudo asitop
    and press the enter key. You will be prompted for you macOS system password, enter it. Now it should run! Press the control and the c keys to exit asitop.
FYI my computer is a MacBook Air (M1, 2020) w/ 16GB RAM running macOS Monterey 12.6. My package manager is pkgsrc (not that it matters as Python comes with macOS) To install pkgsrc on your Mac: https://pkgsrc.joyent.com/install-on-macos/ (again, NOT NECESSARY for asitop, just a really good package manager I like)
Thanks for the step-by-step instructions! Worked perfectly for me.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.