Opened 11 years ago

Closed 10 years ago

#43435 closed defect (fixed)

Can't start Glances

Reported by: ruipacheco (Rui Pacheco) Owned by: g5pw (Aljaž Srebrnič)
Priority: Normal Milestone:
Component: ports Version: 2.2.1
Keywords: Cc:
Port: glances

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Tried to start Glances and got the following exception:

$ glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 53
    def _bypass_ensure_directory(name, mode=0777):
                                               ^
SyntaxError: invalid token

Change History (34)

comment:1 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Owner: changed from macports-tickets@… to g5pw@…
Port: glances added

It works fine for me. Why is anything installed by MacPorts using "/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py"?

comment:2 Changed 11 years ago by ruipacheco (Rui Pacheco)

This is a virtualenv I had enabled when I installed Glances. Is Macports using Python from virtualenvs or the system binary?

comment:3 Changed 11 years ago by g5pw (Aljaž Srebrnič)

That's maybe because PYTHONPATH is still set up for the virtualenv. Can you try launching glances in a new session?

comment:4 Changed 11 years ago by ruipacheco (Rui Pacheco)

$ glances

zsh: command not found: glances

comment:5 Changed 11 years ago by g5pw (Aljaž Srebrnič)

well, that is odd. Can you try uninstalling glances and installing it again?

comment:6 Changed 11 years ago by ruipacheco (Rui Pacheco)

Activated the same virtualenv and issued the command:

sudo port uninstall glances

which terminated successfully. I then opened a new tab, confirmed no virtualenv was enabled and ran the following command:

sudo port install glances

I then tried to run glances and got pretty much the same error:

$ glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 53
    def _bypass_ensure_directory(name, mode=0777):
                                               ^
SyntaxError: invalid token
ruipacheco on traitor.local in ~/Projects/mtcompany/api.xxx.com(24h9m|master*)

$ which python
/usr/bin/python

comment:7 Changed 11 years ago by g5pw (Aljaž Srebrnič)

I don't know precisely how virtualenv works, but I know it changes some env variables. Could you post the output of echo $PYTHONPATH and echo $PATH?

comment:8 Changed 11 years ago by ruipacheco (Rui Pacheco)

With virtualenv enabled:

$ echo $PYTHONPATH
/Users/ruipacheco/.venvburrito/lib/python2.7/site-packages:/Users/ruipacheco/.venvburrito/lib/python
echo $PATH
/Users/ruipacheco/.virtualenvs/useclark/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

without virtualenv

$ echo $PYTHONPATH
/Users/ruipacheco/.venvburrito/lib/python2.7/site-packages:/Users/ruipacheco/.venvburrito/lib/python
echo $PATH
/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

I see that PYTHONPATH is the same for both. I suspect that virtualenv is gumming things up.

comment:9 Changed 11 years ago by g5pw (Aljaž Srebrnič)

Yes, that's exactly the issue. Your PYTHONPATH is not being reset. Can you do a export PYTHONPATH="" and then try launching glances again?

comment:10 Changed 11 years ago by ruipacheco (Rui Pacheco)

ruipacheco on traitor in ~
$ export PYTHONPATH=""
ruipacheco on traitor in ~
$ glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named 'pkg_resources'
ruipacheco on traitor in ~
$

comment:11 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Ok, maybe I found out what was the issue. Do you have setuptools installed?

You can find that out with port installed py34-setuptools.

Last edited 10 years ago by g5pw (Aljaž Srebrnič) (previous) (diff)

comment:12 Changed 10 years ago by ruipacheco (Rui Pacheco)

I didn't install it with ports but I'm pretty sure it was installed as a dependency by pip or easy_install.

comment:13 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Hmm... But did you install glances using pip? You shouldn't have to call pip or easy_install at all, it should all be done using MacPorts. What's the output of the command port installed py34-setuptools?

comment:14 Changed 10 years ago by ruipacheco (Rui Pacheco)

I installed Glances using Macports.

The output is

$ sudo port install py34-setuptools
Password:
--->  Computing dependencies for py34-setuptools
--->  Fetching archive for py34-setuptools
--->  Attempting to fetch py34-setuptools-3.6_0.darwin_13.noarch.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/py34-setuptools
--->  Attempting to fetch py34-setuptools-3.6_0.darwin_13.noarch.tbz2.rmd160 from http://mse.uk.packages.macports.org/sites/packages.macports.org/py34-setuptools
--->  Installing py34-setuptools @3.6_0
--->  Activating py34-setuptools @3.6_0
--->  Cleaning py34-setuptools
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.

comment:15 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Ah, so it wasn't installed at all! Did you update Macports recently? Glances should work now.

comment:16 Changed 10 years ago by ruipacheco (Rui Pacheco)

ruipacheco at traitor in ~ 
$ sudo port install py34-setuptools
--->  Computing dependencies for py34-setuptools
--->  Fetching archive for py34-setuptools
--->  Attempting to fetch py34-setuptools-3.6_0.darwin_13.noarch.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/py34-setuptools
--->  Attempting to fetch py34-setuptools-3.6_0.darwin_13.noarch.tbz2.rmd160 from http://mse.uk.packages.macports.org/sites/packages.macports.org/py34-setuptools
--->  Installing py34-setuptools @3.6_0
--->  Activating py34-setuptools @3.6_0
--->  Cleaning py34-setuptools
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.

ruipacheco at traitor in ~ 
$ glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 53
    def _bypass_ensure_directory(name, mode=0777):
                                               ^
SyntaxError: invalid token

ruipacheco at traitor in ~ 
$

Should I uninstall and re-install it?

comment:17 Changed 10 years ago by g5pw (Aljaž Srebrnič)

It looks like you still have a virtualenv active. That is interfering with glances. Moreover, it looks like your MacPorts tree is outdated. I don't know why it's trying to access a python2.7 module, as it should use python3.4. Please, open a new terminal window and execute:

sudo port -d selfupdate
sudo port upgrade glances

and then run glances again.

comment:18 Changed 10 years ago by ruipacheco (Rui Pacheco)

$ sudo port -d selfupdate
Password:
Sorry, try again.
Password:
DEBUG: Copying /Users/ruipacheco/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
DEBUG: MacPorts sources location: /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
--->  Updating MacPorts base sources using rsync
receiving file list ... done
base.tar

sent 31264 bytes  received 233049 bytes  48056.91 bytes/sec
total size is 27002880  speedup is 102.16
receiving file list ... done
base.tar.rmd160

sent 64 bytes  received 635 bytes  279.60 bytes/sec
total size is 512  speedup is 0.73
DEBUG: successful verification with key /opt/local/share/macports/macports-pubkey.pem
DEBUG: /usr/bin/tar -C /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp -xf /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/base.tar
MacPorts base version 2.3.0 installed,
DEBUG: Rebuilding and reinstalling MacPorts if needed
MacPorts base version 2.3.0 downloaded.
--->  Updating the ports tree
Synchronizing local ports tree from rsync://rsync.macports.org/release/tarballs/ports.tar
DEBUG: /usr/bin/rsync -rtzv --delete-after  rsync://rsync.macports.org/release/tarballs/ports.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
receiving file list ... done
ports.tar

sent 54882 bytes  received 112897 bytes  37284.22 bytes/sec
total size is 61235200  speedup is 364.98
DEBUG: /usr/bin/rsync -rtzv --delete-after  rsync://rsync.macports.org/release/tarballs/ports.tar.rmd160 /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
receiving file list ... done
ports.tar.rmd160

sent 64 bytes  received 636 bytes  280.00 bytes/sec
total size is 512  speedup is 0.73
DEBUG: successful verification with key /opt/local/share/macports/macports-pubkey.pem
DEBUG: /usr/bin/tar -C /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp -xf /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports.tar
DEBUG: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/tarballs/PortIndex_darwin_13_i386/PortIndex /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
receiving file list ... done
PortIndex

sent 19636 bytes  received 20571 bytes  16082.80 bytes/sec
total size is 10601627  speedup is 263.68
DEBUG: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/tarballs/PortIndex_darwin_13_i386/PortIndex.rmd160 /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
receiving file list ... done
PortIndex.rmd160

sent 64 bytes  received 636 bytes  280.00 bytes/sec
total size is 512  speedup is 0.73
DEBUG: successful verification with key /opt/local/share/macports/macports-pubkey.pem
--->  MacPorts base is already the latest version
DEBUG: Setting MacPorts sources ownership to root

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated
$ sudo port upgrade outdated
// This upgraded git
$ sudo port upgrade glances
--->  Scanning binaries for linking errors
--->  No broken files found.
$ glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 53
    def _bypass_ensure_directory(name, mode=0777):
                                               ^
SyntaxError: invalid token

comment:19 Changed 10 years ago by ruipacheco (Rui Pacheco)

Also, virtualenv is NOT active.

comment:20 Changed 10 years ago by g5pw (Aljaž Srebrnič)

This line

"/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py"

suggests it somehow still uses the virtualenv. Can you try to move/rename the .venvburrito directory temporarily?

Can you post the output of the env | grep -i python command, too?

Last edited 10 years ago by g5pw (Aljaž Srebrnič) (previous) (diff)

comment:21 Changed 10 years ago by ruipacheco (Rui Pacheco)

ruipacheco at traitor in ~/Projects/mtcompany/geddit-reader (master●)
$ mv ~/.venvburrito ~/.venvburrito-rui

ruipacheco at traitor in ~/Projects/mtcompany/geddit-reader (master●)
$ glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 9, in <module>
    load_entry_point('Glances==1.7.7', 'console_scripts', 'glances')()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources.py", line 2439, in load_entry_point
    return ep.load()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources.py", line 2155, in load
    ['__name__'])
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/glances/glances.py", line 183, in <module>
    locale.setlocale(locale.LC_ALL, '')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/locale.py", line 592, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Will also open a ticket with venvburrito.

comment:22 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Can you post the output of the env | grep -i python command, too?

Last edited 10 years ago by g5pw (Aljaž Srebrnič) (previous) (diff)

comment:23 Changed 10 years ago by ruipacheco (Rui Pacheco)

PYTHONPATH=/Users/ruipacheco/.venvburrito/lib/python2.7/site-packages:/Users/ruipacheco/.venvburrito/lib/python

comment:24 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Thank you. What about env | grep LC ?

comment:25 Changed 10 years ago by ruipacheco (Rui Pacheco)

LC_CTYPE=UTF-8

comment:26 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Ok, that is not a valid setting for LC_CTYPE. Do you set that in some config file?

Also, the PYTHONPATH variable was confusing python3.4, so it picked up the modules in .venvburrito instead of the MacPorts modules path.

comment:27 Changed 10 years ago by ruipacheco (Rui Pacheco)

I really don't know. Don't think so but can't be sure.

comment:28 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Can you try running this

LC_CTYPE="en_US.UTF-8" glances

comment:29 Changed 10 years ago by ruipacheco (Rui Pacheco)

$ LC_CTYPE="en_US.UTF-8" glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/ruipacheco/.venvburrito/lib/python/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 53
    def _bypass_ensure_directory(name, mode=0777):
                                               ^
SyntaxError: invalid token

comment:30 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Ah, you already renamed the directory back. Try this then:

PYTHONPATH="" LC_CTYPE="en_US.UTF-8" glances

comment:31 Changed 10 years ago by ruipacheco (Rui Pacheco)

Perfect!

What should I fix?

comment:32 Changed 10 years ago by g5pw (Aljaž Srebrnič)

1) You should fix your locale. Find out in your dotfiles where the LC_CTYPE is set.

2) Fix the PYTHONPATH variable. It looks like it's always pointing to the virtual environment. That can't be right, there must be a way to not use it, but I don't know virutalenv-burrito enough to help you, sorry.

Last edited 10 years ago by g5pw (Aljaž Srebrnič) (previous) (diff)

comment:33 Changed 10 years ago by ruipacheco (Rui Pacheco)

Thank you very much for your help. I believe this issue has been fixed.

I've opened a ticket with the virtualenv-burrito people and lets see where that goes.

Last edited 10 years ago by ruipacheco (Rui Pacheco) (previous) (diff)

comment:34 Changed 10 years ago by g5pw (Aljaž Srebrnič)

Resolution: fixed
Status: newclosed

You're welcome! I also ensured setuptools is always installed with a change in r120639.

Note: See TracTickets for help on using tickets.