问题
I know I am doing something really stupid here but I have tried the things I can think of.
Here is the relevant portion of my session:
$ wget http://pjmedia.com/instapundit/
-bash: wget: command not found
$ cd ..
$ pip install wget
Requirement already satisfied (use --upgrade to upgrade): wget in
./anaconda/lib/python2.7/site-packages
$
I have restarted my computer and that does not help. I am using Mac OX X with the El Capitan system installed. Does this have something to do with the PATH variable? I found something on the internet that seemed similar to my problem with another program on the Windows system, but I have found nothing for the Mac OS. I tried installing it from my root directory but the system won't let pip install it because it is already installed. Can anyone point me in the right direction?
EDIT: I would like to thank Max, Bill and kenorb. I have learned more here for free in 10 minutes than I have in a week at some commercial sites. Is there some way to mark my question as answered so that people don't have to keep wasting their time reading my question?
回答1:
Use some OS X package manager like Homebrew (brew) or MacPorts, as pip is used for python modules:
brew install wget
回答2:
Wget the shell command is probably easiest to get on OSX by using Homebrew, and then running brew install wget
.
What you've got there is the python module wget, which follows the same name. It can be used by running python -m wget [options] <URL>
, where your options are to supply an output file name with -o
. You could always alias this to wget in your .bashrc!
回答3:
pip
installs Python modules. In some cases that includes installing a command-line utility as well, but as far as I can tell, with this module that is not the case. So unless you are going to write a Python script that uses the wget
module and fetches the file, this won't do what you want.
The easiest way to install wget
is with homebrew, but that does require a small bit of setup. The setup is very worth it, as you can install nearly any "unix" utility from brew, including servers such as nginx or postgresql.
Once homebrew is set up, simply brew install wget
and you should be set.
来源:https://stackoverflow.com/questions/33069086/wget-is-not-recognized-as-a-command-even-though-it-is-installed