如何在Linux上使用pip为所有用户安装模块?
如何在标准的python环境中安装软件包, 即/usr/local/lib/python2.7/dist-
packages使用pip
新的软件包并使所有用户可以使用该新软件包,而无需使用virtualenv
?
通过使用以下内容,该软件包仅以root权限安装:
$ sudo pip install loremipsumDownloading/unpacking loremipsum
Downloading loremipsum-1.0.5.tar.gz
Running setup.py (path:/tmp/pip_build_root/loremipsum/setup.py)
egg_info for package loremipsum
Installing collected packages: loremipsum
Running setup.py install for loremipsum
Successfully installed loremipsum
Cleaning up...
证明:
$ python -c 'import loremipsum'Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named loremipsum
$ sudo python -c 'import loremipsum'
$ pip install loremipsum
Requirement already satisfied (use --upgrade to upgrade): loremipsum in
/usr/local/lib/python2.7/dist-packages
Cleaning up...
$ cowsay sad
_____
< sad >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
请不要建议我apt-get install python-...
改用。我想知道我的错误以及如何正确使用点子。
$ python --versionPython 2.7.6
$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
$ uname -a
Linux _ 3.19.0-32-generic #37~14.04.1-Ubuntu SMP _ x86_64 GNU/Linux
我猜问题是因为pip
不允许小组和所有人阅读已安装的内容:
$ sudo pip uninstall loremipsumUninstalling loremipsum:
/usr/local/lib/python2.7/dist-packages/loremipsum-1.0.5.egg-info
/usr/local/lib/python2.7/dist-packages/loremipsum/__init__.py
/usr/local/lib/python2.7/dist-packages/loremipsum/__init__.pyc
/usr/local/lib/python2.7/dist-packages/loremipsum/default/dictionary.txt
/usr/local/lib/python2.7/dist-packages/loremipsum/default/sample.txt
/usr/local/lib/python2.7/dist-packages/loremipsum/generator.py
/usr/local/lib/python2.7/dist-packages/loremipsum/generator.pyc
Proceed (y/n)? y
Successfully uninstalled loremipsum
$ sudo pip install loremipsum
Downloading/unpacking loremipsum
Downloading loremipsum-1.0.5.tar.gz
Running setup.py (path:/tmp/pip_build_root/loremipsum/setup.py) egg_info for package loremipsum
Installing collected packages: loremipsum
Running setup.py install for loremipsum
Successfully installed loremipsum
Cleaning up...
$ sudo ls -al /usr/local/lib/python2.7/dist-packages/loremipsum
total 60
drwxr-s--- 3 root staff 4096 Apr 27 22:06 .
drwxrwsr-x 18 root staff 4096 Apr 27 22:06 ..
drwxr-s--- 2 root staff 4096 Apr 27 22:06 default
-rw-r----- 1 root staff 16182 Apr 27 22:06 generator.py
-rw-r----- 1 root staff 16323 Apr 27 22:06 generator.pyc
-rw-r----- 1 root staff 6130 Apr 27 22:06 __init__.py
-rw-r----- 1 root staff 6869 Apr 27 22:06 __init__.pyc
回答:
你可能有一个错误的umask
设定所讨论这里
从您的上一次编辑,我想您umask
已设置为027
。试着做
sudo pip uninstall loremipsumumask 022
sudo pip install loremipsum
以上是 如何在Linux上使用pip为所有用户安装模块? 的全部内容, 来源链接: utcz.com/qa/432910.html