安装没有root访问权限的python软件包

安装没有root访问权限的python软件包

本文介绍了安装没有root访问权限的python软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我使用的服务器上安装python软件包networkx,在问这个问题之前,我会先搜索

I want to install python package networkx in the server I use, and I do search before I ask this question, it says to use

pip install --user networkx

但是它不起作用并且linux错误是

but it doesn't work and the linux error is

Usage: /usr/bin/pip install [OPTIONS] PACKAGE_NAMES...

/usr/bin/pip install: error: no such option: --user

有人可以帮忙吗?如何在服务器中安装networkx软件包?

anyone can help? How can I install networkx package in the server?

推荐答案

如果 virtualenv 是安装在服务器上,您可以创建一个虚拟环境:

If virtualenv is installed on the server, you can create a virtual environment:

virtualenv your_env_name

然后将其激活:

source your_env_name/bin/activate

然后通过

pip install packagename

但是,如果尚未安装virtualenv,则应查看,已经回答了相同的问题.

However, if virtualenv is not installed yet, you should take a look at this thread where the same question has been answered already.

为每个项目使用单独的virtualenv还是更好,因为这样您就可以轻松地使用以下内容导出依赖项

It is still better to use a separate virtualenv for each of your projects, because then you can easily export your dependencies using

pip freeze > requirements.txt

您可以将此Requirement.txt添加到版本控制中,然后,如果您想在另一台计算机上安装项目,则可以一次安装所有依赖项而不会弄乱版本号等:

You could add this requirements.txt to your version control, and later, if you want to install your project on another machine, you can install all dependencies at once without messing with version numbers etc:

pip install -r requirements.txt

这篇关于安装没有root访问权限的python软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 13:14