【发布时间】:2016-10-29 23:04:41
【问题描述】:
我在 OS X Yosemite 10.10.5 上安装了 Python 2.7。我想通过 PIP 安装 NPM,命令显示成功,并且我在 /Library/Python/2.7/site-packages/ 中有一个名为 npm 的目录,但是使用 NPM 执行任何操作都会产生“找不到命令”。
这就是我安装 PIP 和 NPM 的方式:
第 1 步
sudo easy_install pip
将此作为输出:
Reading https://pypi.python.org/simple/pip/
Best match: pip 8.1.2
Downloading https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz#md5=87083c0b9867963b29f7aba3613e8f4a
Processing pip-8.1.2.tar.gz
Writing /tmp/easy_install-v4g_ZO/pip-8.1.2/setup.cfg
Running pip-8.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-v4g_ZO/pip-8.1.2/egg-dist-tmp-5Ku7Ds
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
Adding pip 8.1.2 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Installed /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
第 2 步:
sudo -H pip install npm
将此作为输出:
Collecting npm
Using cached npm-0.1.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): optional-django==0.1.0 in /Library/Python/2.7/site-packages (from npm)
Installing collected packages: npm
Running setup.py install for npm ... done
第 3 步:
npm -v
将此作为输出:
-bash: npm: command not found
这是我的 $PATH 变量中的内容,但为了便于阅读,将其分成单独的行。需要注意的是这些是我从别人的机器上复制过来的,而我的机器没有/usr/local/lib目录。
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/opt/local/bin:
/opt/local/sbin:
/usr/local/lib/python2.7:
/usr/local/lib/python2.7/site-packages:
/usr/local/lib/node_modules:
/usr/bin/python2.7:
/Library/Python/2.7/site-packages/npm
我对 Linux 并不陌生,但我是 OS X 的新手,所以这很明显我忽略了。
【问题讨论】:
标签: macos python-2.7 npm pip