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

OS X Installation issue #423

Closed
andreysamode opened this issue Mar 27, 2016 · 10 comments
Closed

OS X Installation issue #423

andreysamode opened this issue Mar 27, 2016 · 10 comments

Comments

@andreysamode
Copy link

Hello,

I installed proselint on OS X, but I can't seem to be able to execute it.

Steps I performed to install:
sudo port install py-pip34
sudo pip-3.4 install proselint

The files installed successfully into /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/proselint, but when I type "proselint" and enter, I get "-bash: proselint: command not found".

How do I actually run proselint from command line?
Do I need to configure the path to an executable?

Thanks,
Andrey.

@suchow
Copy link
Member

suchow commented Mar 31, 2016

I wonder if this has something to do with using pip-3.4. Can you see if the same issue occurs if you run pip install proselint?

@andreysamode
Copy link
Author

Thanks for the reply.

I did have the same issue with "sudo port install py-pip", which installs pip-2.7. The command then becomes "sudo pip-2.7 install proselint", and there is no "proselint" executable.

Where does your "proselint" command point? I see the files of proselint in the python install directory, but there isn't a "proselint" binary that I can see.

Perhaps I'm misunderstanding how this is supposed to work? I'm not familiar with python. Am I supposed to be executing "proselint" command from a special python shell? I'm just trying it from the command line.

@jeremiahblatz
Copy link

I believe this is using some cool Python feature that your (and my) version of Python/MacOS/whatever doesn't support. I wish it did. If you're lazy and value expediency over correctness, you can do what I did and create a stupid wrapper:

#!/usr/bin/env python

import proselint.command_line
proselint.command_line.proselint()

@suchow
Copy link
Member

suchow commented Apr 3, 2016

@MrAndrey Is there a reason why you are installing Python on OS X, which includes one already? What happens if you use the system Python, pip install proselint?

@jeremiahblatz What OS and Python are you using?

@mpacer
Copy link
Member

mpacer commented Apr 3, 2016

So I use a different process based on brew, are there any weird quirks to macports that would cause this?

Why are you installing 3.4 rather than 3.5? It shouldn't make a difference, but if you use pip3 install proselint with no sudo, what happens? Do you get permission errors? Is that the reason why you are using sudo? You should be able to install proselint without needing root access, so I wonder if part of whats happening is that proselint is being shielded from some search process (and/or is being put in a part of your system that your path doesn't have access to).

I think by default we install to /usr/local/bin/proselint, what is returned if you run echo $PATH in your terminal?

Also, just want to make sure; @jeremiahblatz, what happens if you write the same wrapper using python3 instead of python?

#!/usr/bin/env python3

import proselint.command_line
proselint.command_line.proselint()

Does that still work? (I'm not saying that these things are going to be fixing your problem, but these are the things I would do to see what is going on with your python executables).

@MrAndrey Are you running this from inside a virtualenv?

@suchow Is there any reason why the click package might not be running to build the CLI?

@andreysamode
Copy link
Author

Thanks for the replies, everyone. I'll do my best to answer all of the above questions and help troubleshoot this.

I'm using Mavericks. When I initially typed "pip install proselint", I got command not found, so I had to install pip. To do that using MacPorts, I typed "sudo port install pip". It gave me package not found. I did a search and found that there's a big list of different versions of pip, all starting with "py-pip". I typed "sudo port install py-pip", and it installed version 2.7. After it installed all the dependencies, "proselint" command gave me a command not found error. I decided to try a higher version of pip, the highest available being 3.4. I followed the same steps, and ended up with same results.

So, @michaelpacer to follow your suggestion, I uninstalled proselint (using sudo), then typed "pip-3.4 install proselint" without sudo. Below is output. Permission errors.

creating /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/proselint error: could not create '/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/proselint': Permission denied ---------------------------------------- Command "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/private/var/folders/xf/gmpspcrs3gj3xht3t6tq4yhh0000gn/T/pip-build-ms09rjla/proselint/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/xf/gmpspcrs3gj3xht3t6tq4yhh0000gn/T/pip-xvvn9skg-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/xf/gmpspcrs3gj3xht3t6tq4yhh0000gn/T/pip-build-ms09rjla/proselint/

I checked, and /usr/local/bin/proselint is not there.
Here is the output of echo $PATH:
/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I'm not in any virtual environment. This is running on a regular system on my Macbook Pro.

Thanks much for troubleshooting this with me.
Andrey.

@mpacer
Copy link
Member

mpacer commented Apr 4, 2016

So, because you can use sudo you're an admin, which makes me think you could mess with the permissions, and that actually this is a permissions issue…but I could be wrong.

If you're using Mavericks, then you shouldn't have any of the El Capitan issues regarding /usr/local access, so you should be able to resolve these as pure permissions issues.

Others might disagree, but I tend to not like using sudo as part of my pip installs (or brew installs for that matter). I don't want to give these packages root access and I don't want to be typing my password constantly, so if I have to use sudo often it makes me think that I've set something up incorrectly in my build system.

Notably, permission issues can sometimes manifest in the kind of problem that you are having, where you install something but then it doesn't seem to exist because when it is invoked, the thing that does the invoking does not have the correct permissions to execute the process needed to find the relevant command semantics.

Did you try sudo proselint after using the sudo pip install? I don't think that should work, but it is what I would do next as a troubleshooting step.

Since you have /usr/local/bin on your path you should be able to find /usr/local/bin/proselint just using the CLI. So that (on its own) shouldn't be the problem.

If you don't want to try to troubleshoot that (an understandable position) I'd take a shot at what is suggested here http://kazhack.org/?post/2014/12/12/pip-gem-install-without-sudo and try using --user as a flag that you pass to pip. It's not the solution I'd like, but it might solve it for you.

–––––––––––

Also, is the reason you're using mac ports vs. brew that you've been using mac ports and are more comfortable with it than homebrew?
If you have someone that can walk you through the process or if you are feeling bold, I would suggest trying brew for package management. For example, you'd be able to get python 3.5 just by using brew install python3. There are some finicky things that you might have to do with pyenv if you want to have multiple installations of python3 installed at the same time. But I don't think you are worried about that based on what you've been saying. Additionally, you could try to use anaconda and install things with conda but I actually don't use anaconda so I cannot say whether it is going to be better for your situation.

All of that said, @suchow and I don't want people to have to change their workflows to get proselint to work with them, but rather to change proselint to ensure it works within others' workflows. So, even if you do want to switch (which I really do recommend if you can take the time to do so) could you hold off on doing so until we figure this out in your current workflow?

Also, my responses will be intermittent as I'm spending almost all of my time writing my dissertation; writing this counts as one of my breaks 😅. Fortunately it can be relaxing to think through these kinds of things. Happy to help!

@andreysamode
Copy link
Author

I finally got it to work.

Here are the steps that I took:
First, I did port installed to see which python packages I had and removed them all:
sudo port uninstall --follow-dependents python27
sudo port uninstall --follow-dependents python34

Then I upgraded my MacPorts packages:
sudo port upgrade outdated

Then I installed latest python and set it as default:
sudo port install python35
sudo port select --set python python35

Then I closed and reopened the shell.

Then I installed py35-pip. Trying to install "py-pip" still tried to get pip for python 2.7, so I had to be specific.
sudo port install py35-pip

Then, following @michaelpacer's suggestion, I installed proselint without sudo:
pip3 install proselint

Now when I type "proselint --demo" into terminal, I get a list of corrections, as expected, and I also got it to work with Sublime Text (which is a bit of an undertaking in itself).

Many thanks for your help!
Andrey.

@jeremiahblatz
Copy link

@suchow I'm running stock Python (2.7.4) on MacOS X (10.10.5). (I know Apple's Python is bad, but, as I alluded to above, I'm a big fan of expediency.)

@michaelpacer : I don't have Python 3 installed, so that wrapper fails with the predictable result of python3: command not found

Anyway, the fact that people are actually interested caused me to dig a little deeper. My problem was, in fact, the dumbest possible problem: /usr/local/share/python/ wasn't in my $PATH. I added that to my path, and now everything works without my silly wrapper.

@andreysamode
Copy link
Author

I just tried to follow my own instructions on an older machine running Snow Leopard and it didn't work. I'm posting the extra steps here for reference.

  1. Install Macports
  2. Install Python 3 (download from their website)
  3. sudo port install py35-pip (installs python and all dependencies)
  4. sudo port select --set python python35
  5. pip3 install --upgrade pip
  6. pip3 install click (this gets installed as a proselint dependency, but I installed it on its own)
  7. pip3 install proselint

Now I have the /Library/Frameworks/Python.framework/Versions/3.5/bin/proselint executable. It wasn't there when I tried it without downloading python or using pip instead of pip3. Odd, but whatever works.

Keep up the good work!

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

4 participants