如何pip安装到外部驱动器? [英] How to pip install to an external drive?

查看:25
本文介绍了如何pip安装到外部驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 python 安装的 USB,我随身携带 &在没有安装 python 的计算机上使用/不允许你安装模块.我想在上面安装一个 python 包,但一直有问题.例如,让我使用包 rebound-cli.如果我 pip install reverse-cli,该软件包将安装到我的电脑安装 python D:\Program Files (x86)\Python36-32.我的USB python安装目录是H:\.bin\Program Files\Python.我试过以下<代码>点安装反弹-cli -e "H:\.bin\Program Files\Python\Lib\site-packages"点安装反弹-cli -e "H:\.bin\Program Files\Python"他们都给了我错误目录 'H:\\.bin\\Program Files\\Python\\Lib\\site-packages' 不可安装.找不到文件setup.py".目录H:\\.bin\\Program Files\\Python"不可安装.找不到文件setup.py".

I have a USB with a python installation that I carry around with me & use on computers that don't have python installed/don't allow you to install modules. I'd like to install a python package onto it but have been having trouble. Let me use the package rebound-clifor example. If I pip install rebound-cli, the package is installed onto my PC installation of python D:\Program Files (x86)\Python36-32. The directory of my USB python installation is H:\.bin\Program Files\Python. I've tried the following pip install rebound-cli -e "H:\.bin\Program Files\Python\Lib\site-packages" pip install rebound-cli -e "H:\.bin\Program Files\Python" They both give me the error(s) Directory 'H:\\.bin\\Program Files\\Python\\Lib\\site-packages' is not installable. File 'setup.py' not found. Directory 'H:\\.bin\\Program Files\\Python' is not installable. File 'setup.py' not found.

我也试过H:\.bin\Program Files\Python\Scripts\pip.exe"安装反弹cli但是已经收到错误启动器中的致命错误:无法使用e:\.bin\program files\python\python.exe"H:\.bin\Program Files\Python\Scripts\pip.exe"安装反弹创建进程-cli'

I've also tried "H:\.bin\Program Files\Python\Scripts\pip.exe" install rebound-cli But have received the error Fatal error in launcher: Unable to create process using '"e:\.bin\program files\python\python.exe" "H:\.bin\Program Files\Python\Scripts\pip.exe" install rebound-cli'

推荐答案

由于您没有明确指定要使用的 pip 二进制文件,因此该软件包已安装在您的 PC 上.

The package is installed on your PC because you did not explicitly specify which pip binary to use.

如果您执行where pip,它会显示当前处于活动状态的pip 二进制文件的目录.在您的情况下,它很可能位于 D: 目录中.

If you execute where pip, it would display the directory of the pip binary which is currently active. In your case, it will most likely be in D: directory.

要在您的 USB 中安装软件包,请使用 h:\<path>\<to>\<pip>\pip install reboot-cli.

To install packages in your USB, use h:\<path>\<to>\<pip>\pip install rebound-cli.

更好的选择是,在您的 USB 中创建一个虚拟环境,并在您想在 USB 中使用 Python 时激活该环境.使用环境将使您无需明确指定位于 USB 中的 pip/python 二进制文件的路径

A better option would be, creating a virtual environment in your USB and activating that environment whenever you want to use Python in your USB. Using an environment will save you from the need to explicitly specify the path to pip/python binary located in your USB

这篇关于如何pip安装到外部驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆