标签归档:pip

Windows Scipy安装:未找到Lapack / Blas资源

问题:Windows Scipy安装:未找到Lapack / Blas资源

我正在尝试在64位Windows 7桌面上安装python和一系列软件包。我已经安装了Python 3.4,已经安装了Microsoft Visual Studio C ++,并且已经成功安装了numpy,pandas和其他一些软件。尝试安装scipy时出现以下错误;

numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

我正在离线使用pip install,我正在使用的安装命令是;

pip install --no-index --find-links="S:\python\scipy 0.15.0" scipy

我已经阅读了有关要求编译器的信息,如果我正确理解的话,则是VS C ++编译器。我正在使用2010版本,就像在使用Python 3.4。这对于其他软件包也有效。

我必须使用窗口二进制文件还是有办法让pip安装正常工作?

非常感谢您的帮助

I am trying to install python and a series of packages onto a 64bit windows 7 desktop. I have installed Python 3.4, have Microsoft Visual Studio C++ installed, and have successfully installed numpy, pandas and a few others. I am getting the following error when trying to install scipy;

numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

I am using pip install offline, the install command I am using is;

pip install --no-index --find-links="S:\python\scipy 0.15.0" scipy

I have read the posts on here about requiring a compiler which if I understand correctly is the VS C++ compiler. I am using the 2010 version as I am using Python 3.4. This has worked for other packages.

Do I have to use the window binary or is there a way I can get pip install to work?

Many thanks for the help


回答 0

此处介绍了在Windows 7 64位系统上不安装SciPy的BLAS / LAPACK库的解决方案:

http://www.scipy.org/scipylib/building/windows.html

安装Anaconda会容易得多,但是如果不付费就无法获得Intel MKL或GPU的支持(它们在MKL Optimizations和Anaconda的加速附件中-我不确定他们是否同时使用PLASMA和MAGMA) 。通过MKL优化,numpy在大型矩阵计算上的性能优于IDL十倍。MATLAB内部使用Intel MKL库并支持GPU计算,因此如果他们是学生,则不妨将其作为价格使用(MATLAB为50美元,并行计算工具箱为10美元)。如果您获得了Intel Parallel Studio的免费试用版,它将附带MKL库以及C ++和FORTRAN编译器,如果您想在Windows上从MKL或ATLAS安装BLAS和LAPACK,它们将派上用场:

http://icl.cs.utk.edu/lapack-for-windows/lapack/

Parallel Studio还带有Intel MPI库,可用于群集计算应用程序及其最新的Xeon处理器。尽管使用MKL优化来构建BLAS和LAPACK的过程并非易事,但针对Python和R这样做的好处却是巨大的,如以下英特尔网络研讨会所述:

https://software.intel.com/zh-CN/articles/powered-by-mkl-accelerating-numpy-and-scipy-performance-with-intel-mkl-python

Anaconda和Enthought通过使此功能和其他一些事情更易于部署而建立了业务。但是,愿意做一点工作(一点学习)的人可以免费使用它。

对于那些谁使用R,你现在可以得到优化MKL BLAS和LAPACK免费使用R打开从革命Analytics(分析)。

编辑:Anaconda Python现在附带MKL优化,以及通过Intel Python发行版对许多其他Intel库优化的支持。但是,Accelerate库(以前称为NumbaPro)中对Anaconda的GPU支持仍然超过1万美元!最好的替代方法可能是PyCUDA和scikit-cuda,因为铜头鱼(基本上是Anaconda Accelerate的免费版本)不幸在五年前停止开发。如果有人想在他们离开的地方接机,可以在这里找到。

The solution to the absence of BLAS/LAPACK libraries for SciPy installations on Windows 7 64-bit is described here:

http://www.scipy.org/scipylib/building/windows.html

Installing Anaconda is much easier, but you still don’t get Intel MKL or GPU support without paying for it (they are in the MKL Optimizations and Accelerate add-ons for Anaconda – I’m not sure if they use PLASMA and MAGMA either). With MKL optimization, numpy has outperformed IDL on large matrix computations by 10-fold. MATLAB uses the Intel MKL library internally and supports GPU computing, so one might as well use that for the price if they’re a student ($50 for MATLAB + $10 for the Parallel Computing Toolbox). If you get the free trial of Intel Parallel Studio, it comes with the MKL library, as well as C++ and FORTRAN compilers that will come in handy if you want to install BLAS and LAPACK from MKL or ATLAS on Windows:

http://icl.cs.utk.edu/lapack-for-windows/lapack/

Parallel Studio also comes with the Intel MPI library, useful for cluster computing applications and their latest Xeon processsors. While the process of building BLAS and LAPACK with MKL optimization is not trivial, the benefits of doing so for Python and R are quite large, as described in this Intel webinar:

https://software.intel.com/en-us/articles/powered-by-mkl-accelerating-numpy-and-scipy-performance-with-intel-mkl-python

Anaconda and Enthought have built businesses out of making this functionality and a few other things easier to deploy. However, it is freely available to those willing to do a little work (and a little learning).

For those who use R, you can now get MKL optimized BLAS and LAPACK for free with R Open from Revolution Analytics.

EDIT: Anaconda Python now ships with MKL optimization, as well as support for a number of other Intel library optimizations through the Intel Python distribution. However, GPU support for Anaconda in the Accelerate library (formerly known as NumbaPro) is still over $10k USD! The best alternatives for that are probably PyCUDA and scikit-cuda, as copperhead (essentially a free version of Anaconda Accelerate) unfortunately ceased development five years ago. It can be found here if anybody wants to pick up where they left off.


回答 1

以下链接应解决Windows和SciPy的所有问题;只需选择适当的下载即可。我能够毫无问题地安装该软件包。我尝试过的所有其他解决方案都让我头疼。

来源:http : //www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

命令:

 pip install [Local File Location]\[Your specific file such as scipy-0.16.0-cp27-none-win_amd64.whl]

假定您已经安装了以下软件:

  1. 使用Python工具安装Visual Studio 2015/2013
    (在2015年安装时已集成到安装选项中)

  2. 安装用于Python的Visual Studio C ++编译器
    来源:http : //www.microsoft.com/zh-cn/download/details.aspx?id=44266
    文件名:VCForPython27.msi

  3. 选择安装的Python版本
    来源:python.org
    文件名(例如):python-2.7.10.amd64.msi

The following link should solve all problems with Windows and SciPy; just choose the appropriate download. I was able to pip install the package with no problems. Every other solution I have tried gave me big headaches.

Source: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

Command:

 pip install [Local File Location]\[Your specific file such as scipy-0.16.0-cp27-none-win_amd64.whl]

This assumes you have installed the following already:

  1. Install Visual Studio 2015/2013 with Python Tools
    (Is integrated into the setup options on install of 2015)

  2. Install Visual Studio C++ Compiler for Python
    Source: http://www.microsoft.com/en-us/download/details.aspx?id=44266
    File Name: VCForPython27.msi

  3. Install Python Version of choice
    Source: python.org
    File Name (e.g.): python-2.7.10.amd64.msi


回答 2

我的python版本是2.7.10,64位Windows 7。

  1. scipy-0.18.0-cp27-cp27m-win_amd64.whl从下载http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
  2. 打开 cmd
  3. 确保scipy-0.18.0-cp27-cp27m-win_amd64.whl位于cmd当前目录中,然后键入pip install scipy-0.18.0-cp27-cp27m-win_amd64.whl

将成功安装。

My python’s version is 2.7.10, 64-bits Windows 7.

  1. Download scipy-0.18.0-cp27-cp27m-win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
  2. Open cmd
  3. Make sure scipy-0.18.0-cp27-cp27m-win_amd64.whl is in cmd‘s current directory, then type pip install scipy-0.18.0-cp27-cp27m-win_amd64.whl.

It will be successful installed.


回答 3

抱歉necro,但这是第一个Google搜索结果。这是为我工作的解决方案:

  1. http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy下载numpy + mkl滚轮 。使用与python版本相同的版本(使用python -V检查)。例如。如果您的python是3.5.2,请下载显示cp35的转盘

  2. 打开命令提示符,然后导航到下载滚轮的文件夹。运行命令:pip install [wheel文件名]

  3. 从以下网址下载SciPy滚轮:http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy (类似于上述步骤)。

  4. 如上所述,pip install [wheel的文件名]

Sorry to necro, but this is the first google search result. This is the solution that worked for me:

  1. Download numpy+mkl wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy. Use the version that is the same as your python version (check using python -V). Eg. if your python is 3.5.2, download the wheel which shows cp35

  2. Open command prompt and navigate to the folder where you downloaded the wheel. Run the command: pip install [file name of wheel]

  3. Download the SciPy wheel from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy (similar to the step above).

  4. As above, pip install [file name of wheel]


回答 4

这是我一切正常的顺序。第二点是最重要的。科学需要Numpy+MKL,而不仅仅是香草Numpy

  1. 安装python 3.5
  2. pip install "file path"(从此处http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy下载Numpy + MKL轮子)
  3. pip install scipy

This was the order I got everything working. The second point is the most important one. Scipy needs Numpy+MKL, not just vanilla Numpy.

  1. Install python 3.5
  2. pip install "file path" (download Numpy+MKL wheel from here http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy)
  3. pip install scipy

回答 5

如果您使用的是Windows和Visual Studio 2015

输入以下命令

  • “康达安装numpy的”
  • “康达安装熊猫”
  • “ conda安装scipy”

If you are working with Windows and Visual Studio 2015

Enter the following commands

  • “conda install numpy”
  • “conda install pandas”
  • “conda install scipy”

回答 6

我的5美分;您可以从https://github.com/scipy/scipy/releases安装整个(预编译的)SciPy

祝好运!

My 5 cents; You can just install the entire (pre-compiled) SciPy from https://github.com/scipy/scipy/releases

Good Luck!


回答 7

在Windows中简单快速地安装Scipy

  1. http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy下载适用于您的Python版本的正确Scipy软件包(例如,适用于python 3.5和Windows x64的正确软件包scipy-0.19.1-cp35-cp35m-win_amd64.whl)。
  2. cmd在包含下载的Scipy软件包的目录中打开。
  3. 键入pip install <<your-scipy-package-name>>(例如pip install scipy-0.19.1-cp35-cp35m-win_amd64.whl)。

Simple and Fast Installation of Scipy in Windows

  1. From http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy download the correct Scipy package for your Python version (e.g. the correct package for python 3.5 and Windows x64 is scipy-0.19.1-cp35-cp35m-win_amd64.whl).
  2. Open cmd inside the directory containing the downloaded Scipy package.
  3. Type pip install <<your-scipy-package-name>> (e.g. pip install scipy-0.19.1-cp35-cp35m-win_amd64.whl).

回答 8

对于 python27 1,安装numpy + mkl(下载链接:http : //www.lfd.uci.edu/~gohlke/pythonlibs/)2,安装scipy(在同一站点)OK!

For python27 1、Install numpy + mkl(download link:http://www.lfd.uci.edu/~gohlke/pythonlibs/) 2、install scipy (the same site) OK!


回答 9

英特尔现在免费提供用于Linux / Windows / OS X的Python发行版,称为“ 英特尔Python发行版 ”。

它是一个完整的Python发行版(例如,软件包中包含python.exe),其中包括一些根据Intel的MKL(数学内核库)编译的预安装模块,因此针对更快的性能进行了优化。

发行版包括模块NumPy,SciPy,scikit-learn,pandas,matplotlib,Numba,tbb,pyDAAL,Jupyter等。缺点是升级到最新版本的Python有点晚。例如,从今天(2017年5月1日)开始,发行版提供CPython 3.5,而3.6版本已经发布。但是,如果您不需要这些新功能,则应该很好。

Intel now provides a Python distribution for Linux / Windows / OS X for free called “Intel distribution for Python“.

Its a complete Python distribution (e.g. python.exe is included in the package) which includes some pre-installed modules compiled against Intel’s MKL (Math Kernel Library) and thus optimized for faster performance.

The distribution includes the modules NumPy, SciPy, scikit-learn, pandas, matplotlib, Numba, tbb, pyDAAL, Jupyter, and others. The drawback is a bit of lateness in upgrading to more recent versions of Python. For example as of today (1 May 2017) the distribution provides CPython 3.5 while the 3.6 version is already out. But if you don’t need the new features they should be perfectly fine.


回答 10

安装scikit-fuzzy时我也遇到了同样的错误。我解决了如下错误:

  1. 安装Whl文件Numpy
  2. 安装Scipy,再次是whl文件

根据python版本选择文件,例如python3的amd64和python27的其他win32文件

  1. 然后 pip install --user skfuzzy

我希望,它将为您工作

I was also getting same error while installing scikit-fuzzy. I resolved error as follows:

  1. Install Numpy, a whl file
  2. Install Scipy, again a whl file

choose file according to python version like amd64 for python3 and other win32 file for the python27

  1. then pip install --user skfuzzy

I hope, It will work for you


回答 11

解决方案:

  1. 如许多答案中所指定,请从http://www.lfd.uci.edu/~gohlke/pythonlibs/下载NumPySciPy whl 并安装

    pip install <whl_location>
  2. 从源代码构建BLAS / LAPACK

  3. 使用Miniconda

参考:

  1. ScikitLearn安装
  2. 为scipy安装BLAS和LAPACK的最简单方法?

Solutions:

  1. As specified in many answers, download NumPy and SciPy whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and install with

    pip install <whl_location>
    
  2. Building BLAS/LAPACK from source

  3. Using Miniconda.

Refer:

  1. ScikitLearn Installation
  2. Easiest way to install BLAS and LAPACK for scipy?

回答 12

使用http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy上的资源 可以解决此问题。但是,您应该注意版本兼容性。经过几次尝试,最终我决定卸载python,然后与numpy一起安装了新版本的python,然后安装了scipy,这解决了我的问题。

Using resources at http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy will solve the problem. However, you should be careful about versions compatibility. After trying for several times, finally I decided to uninstall python and then installed a fresh version of python along with numpy and then installed scipy and this resolved my problem.


回答 13

安装python的intel发行版https://software.intel.com/zh-cn/intel-distribution-for-python

更好的python发行版应首先包含它们

install intel’s distribution of python https://software.intel.com/en-us/intel-distribution-for-python

better of for distribution of python should contain them initially


回答 14

这样做,它为我解决了 pip install -U scikit-learn

do this, it solved for me pip install -U scikit-learn


无法安装Python软件包[SSL:TLSV1_ALERT_PROTOCOL_VERSION]

问题:无法安装Python软件包[SSL:TLSV1_ALERT_PROTOCOL_VERSION]

我正在尝试使用安装Python库pip,并收到SSL错误:

~/projects/base  pre-master±  pip install xdict

Collecting xdict
  Could not fetch URL https://pypi.python.org/simple/xdict/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
  Could not find a version that satisfies the requirement xdict (from versions: )
No matching distribution found for xdict

点子版本:点子9.0.1

如何解决此错误?

I am trying to install a Python library using pip, getting an SSL error:

~/projects/base  pre-master±  pip install xdict

Collecting xdict
  Could not fetch URL https://pypi.python.org/simple/xdict/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
  Could not find a version that satisfies the requirement xdict (from versions: )
No matching distribution found for xdict

pip version: pip 9.0.1

How do I fix this error?


回答 0

升级点如下:

curl https://bootstrap.pypa.io/get-pip.py | python

注意:sudo python如果不在虚拟环境中,则可能需要使用以上内容。

(请注意,pip使用pipie进行pip install --upgrade pip升级也不会正确升级。这只是一个鸡与蛋的问题。pip除非使用TLS> = 1.2,否则它将无法正常工作。)

本详细答案所述,这是由于最近对pip的TLS弃用。Python.org网站已停止支持 TLS版本1.0和1.1。

从Python状态页面:

已完成 -滚动式电源不足已完成,并且TLSv1.0和TLSv1.1已被禁用。世界标准时间4月11日15:37


对于PyCharm(virtualenv)用户:

  1. 使用Shell运行虚拟环境。(将“ ./venv/bin/activate”替换为您自己的路径)

    source ./venv/bin/activate
  2. 运行升级

    curl https://bootstrap.pypa.io/get-pip.py | python
  3. 重新启动您的PyCharm实例,然后在Preference中检查您的Python解释器。

Upgrade pip as follows:

curl https://bootstrap.pypa.io/get-pip.py | python

Note: You may need to use sudo python above if not in a virtual environment.

(Note that upgrading pip using pip i.e pip install --upgrade pip will also not upgrade it correctly. It’s just a chicken-and-egg issue. pip won’t work unless using TLS >= 1.2.)

As mentioned in this detailed answer, this is due to the recent TLS deprecation for pip. Python.org sites have stopped support for TLS versions 1.0 and 1.1.

From the Python status page:

Completed – The rolling brownouts are finished, and TLSv1.0 and TLSv1.1 have been disabled. Apr 11, 15:37 UTC


For PyCharm (virtualenv) users:

  1. Run virtual environment with shell. (replace “./venv/bin/activate” to your own path)

    source ./venv/bin/activate
    
  2. Run upgrade

    curl https://bootstrap.pypa.io/get-pip.py | python
    
  3. Restart your PyCharm instance, and check your Python interpreter in Preference.


回答 1

但是,如果curl命令本身因错误而失败,或者即使升级后“ tlsv1警报协议版本”仍然存在pip,则表示操作系统的基础OpenSSL库版本< 1.0.1或Python版本< 2.7.9(或3.4Python 3中的< )不支持较新的TLS 1.2协议这pip需要连接到PyPI中,因为大约一年前。您可以在Python解释器中轻松检查它:

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8o 01 Jun 2010'
>>> ssl.PROTOCOL_TLSv1_2
 AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'

AttributeError(而不是预期的“5”)是指你的Python STDLIB ssl模块,对旧的OpenSSL的lib编译,缺乏对TLSv1.2工作协议(即使OpenSSL库可以或可以在以后更新)的支持。

幸运的是,无需手动升级额外的Python软件包即可解决此问题,而无需升级Python(以及整个系统),详细的逐步指南位于Stackoverflow上

注意,curlpipwget所有依赖于相同的OpenSSL lib中建立SSL连接(使用$ openssl version命令)。从curl版本7.34开始,libcurl支持TLS 1.2 ,但是如果您具有OpenSSL版本1.0.2(或更高版本),则较旧的curl版本应该能够连接。


PS
对于Python 3中,请使用python3pip3无处不在(除非你是在一个VENV / virtualenv中),包括curl从命令上面
$ curl https://bootstrap.pypa.io/get-pip.py | python3 --user

But if the curl command itself fails with error, or “tlsv1 alert protocol version” persists even after upgrading pip, it means your operating system’s underlying OpenSSL library version<1.0.1 or Python version<2.7.9 (or <3.4 in Python 3) do not support the newer TLS 1.2 protocol that pip needs to connect to PyPI since about a year ago. You can easily check it in Python interpreter:

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8o 01 Jun 2010'
>>> ssl.PROTOCOL_TLSv1_2
 AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'

The AttributeError (instead of expected ‘5’) means your Python stdlib ssl module, compiled against old openssl lib, is lacking support for the TLSv1.2 protocol (even if the openssl library can or could be updated later).

Fortunately, it can be solved without upgrading Python (and the whole system), by manually installing extra Python packages — the detailed step-by-step guide is available here on Stackoverflow.

Note, curl and pip and wget all depend on the same OpenSSL lib for establishing SSL connections (use $ openssl version command). libcurl supports TLS 1.2 since curl version 7.34, but older curl versions should be able to connect if you had OpenSSL version 1.0.2 (or later).


P.S.
For Python 3, please use python3 and pip3 everywhere (unless you are in a venv/virtualenv), including the curl command from above:
$ curl https://bootstrap.pypa.io/get-pip.py | python3 --user


回答 2

在OS X上遵循@Anupam的回答后,无论我使用哪种权限运行,都会导致以下错误:

由于环境错误而无法安装软件包:[Errno 13]权限被拒绝:…

最终什么工作是直接从我的浏览器下载一封来自PyPI一个较新的PIP封装(9.0.3) – https://pypi.org/simple/pip/,提取内容,然后PIP本地安装包:

pip install ./pip-9.0.3/

这解决了我的[SSL: TLSV1_ALERT_PROTOCOL_VERSION]错误。

Following @Anupam’s answer on OS X resulted in the following error for me, regardless of permissions I ran it with:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: …

What eventually worked was to download a newer pip package (9.0.3) from PyPI directly from my browser – https://pypi.org/simple/pip/, extract the contents, and then pip install the package locally:

pip install ./pip-9.0.3/

This fixed my [SSL: TLSV1_ALERT_PROTOCOL_VERSION] errors.


回答 3

@Anupam的解决方案对我有用。但是,我必须使用sudo并指定虚拟Python环境的确切位置:

curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python

@Anupam‘s solution worked for me. However, I had to use sudo and specify the exact location of my virtual Python environment:

curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python

回答 4

为了升级本地版本,我使用了一个轻微的变体:

curl https://bootstrap.pypa.io/get-pip.py | python - --user

如果您按照本要点所述将pip和程序包放在主目录下,则会出现此问题。

To upgrade the local version I used a slight variant:

curl https://bootstrap.pypa.io/get-pip.py | python - --user

This problem arises if you keep your pip and packages under your home directory as described in this gist.


回答 5

以下解决方案为我工作:

brew install python2

它还升级pip到版本1.10.1

The following solution worked for me:

brew install python2

It also upgraded pip to version 1.10.1


回答 6

检查您的TLS版本:

python2 -c "import urllib2,json; print(json.loads(urllib2.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])"

如果您的TLS版本低于1.2,则您必须对其进行升级,因为PyPI存储库正处于弃用早期TLS的限制期。

来源- 升级Python的时间:TLS v1.2很快将成为必需

您可以使用以下命令升级TLS版本:

sudo apt-get update && sudo apt-get install openssl libssl-dev

这应该可以解决您的问题。祝好运!

编辑:您可以使用自己的专用python软件包存储库下载软件包,而不管TLS版本如何。 专用Python软件包存储库

Check your TLS version:

python2 -c "import urllib2,json; print(json.loads(urllib2.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])"

If your TLS version is less than 1.2 you have to upgrade it since the PyPI repository is on a brownout period of deprecating early TLS.

Source – Time To Upgrade Your Python: TLS v1.2 Will Soon Be Mandatory

You can upgrade the TLS version using the following command:

sudo apt-get update && sudo apt-get install openssl libssl-dev

This should fix your problem. Good luck!

EDIT: You can download packages using your own private python package repository regardless of TLS version. Private Python Package Repository


回答 7

这对我有用。在python之前添加sudo

curl https://bootstrap.pypa.io/get-pip.py |sudo python

This worked for me. Add sudo before python

curl https://bootstrap.pypa.io/get-pip.py |sudo python

回答 8

对于Python2 WIN10用户:

1.彻底卸载python,包括所有文件夹。

2.获取并安装最新的python-2.7.msi(版本2.7.15)

3.步骤2之后,您可能还会发现pip也已安装。

4.现在,如果尚未更改系统的环境,则可以立即使用pip安装软件包。“ tlsv1警报协议版本”将不会出现。

For Python2 WIN10 Users:

1.Uninstall python thoroughly ,include all folders.

2.Fetch and install the lastest python-2.7.msi (ver 2.7.15)

3.After step 2,you may find pip had been installed too.

4.Now ,if your system’env haven’t been changed,you can use pip to install packages now.The “tlsv1 alert protocol version” will not appear.


回答 9

我尝试了所有现有修补程序,但对我不起作用

我通过在https://www.python.org/downloads/mac-osx/下载.pkg重新安装了python 2.7(还将安装pip)

安装下载pkg后对我有效

I tried all existing fixes and not working for me

I re-install python 2.7 (will also install pip) by downloading .pkg at https://www.python.org/downloads/mac-osx/

works for me after installation downloaded pkg


回答 10

我也遇到了这个问题。潜在的问题是Python 2.7版本<2.7.9中的ssl库不再与pip机制兼容。

如果您在Windows上运行,并且您(像我们一样)无法轻松地从2.7的不兼容版本FWIW升级,我发现如果您从另一个最新版本的Python(例如Python 2.7)的安装中复制以下文件。 15)在另一台机器上进行安装:

    Lib\ssl.py
    libs\_ssl.lib
    DLLs\_ssl.dll

它将有效地将您的SSL层“升级”到受支持的层;这样我们就可以再次使用pip,甚至可以升级pip。

I ran into this problem as well. The underlying problem is that the ssl library in Python 2.7 versions < 2.7.9 is no longer compatible with the pip mechanism.

If you are running on Windows, and you (like us) can’t easily upgrade from an incompatible version of 2.7, FWIW, I found that if you copy the following files from another install of the latest version of Python (e.g. Python 2.7.15) on another machine to your installation:

    Lib\ssl.py
    libs\_ssl.lib
    DLLs\_ssl.dll

it will effectively “upgrade” your SSL layer to one which is supported; we were then be able to use pip again, even to upgrade pip.


回答 11

这对我有用,我安装了最新版本的pip,然后安装了库(ciscoconfparse)。

升级点数:

curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python

This worked for me, I installed latest version of pip and then installed the library (ciscoconfparse).

Upgrading pip:

curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python

回答 12

myenv:

python 2.7.14

点9.0.1

mac osx 10.9.4


mysolution:

  1. get-pip.pyhttps://packaging.python.org/tutorials/installing-packages/手动下载

  2. python get-pip.py


参考:

https://github.com/pypa/warehouse/issues/3293#issuecomment-378468534

https://packaging.python.org/tutorials/installing-packages/

安全下载get-pip.py [1]

运行python get-pip.py。[2]这将安装或升级点子。此外,如果尚未安装setuptools和wheel,则将安装它们。

确保pip,setuptools和wheel最新

尽管仅pip即可从预构建的二进制归档文件进行安装,但是最新的setuptools和wheel项目副本对于确保您也可以从源归档文件进行安装很有用:

python -m pip install --upgrade pip setuptools wheel

myenv:

python 2.7.14

pip 9.0.1

mac osx 10.9.4


mysolution:

  1. download get-pip.py manually from https://packaging.python.org/tutorials/installing-packages/

  2. run python get-pip.py


refs:

https://github.com/pypa/warehouse/issues/3293#issuecomment-378468534

https://packaging.python.org/tutorials/installing-packages/

Securely Download get-pip.py [1]

Run python get-pip.py. [2] This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.

Ensure pip, setuptools, and wheel are up to date

While pip alone is sufficient to install from pre-built binary archives, up to date copies of the setuptools and wheel projects are useful to ensure you can also install from source archives:

python -m pip install --upgrade pip setuptools wheel


回答 13

我也在Windows10上遇到了这个问题,并尝试了所有答案,但没有解决我的问题。

C:\ python367 \ Scripts> pip安装Flask

收集Flask找不到满足Flask要求的版本(来自版本:)找不到Flask的匹配发行版

之后,我发现pip配置文件已被修改。因此,我将设置pip.ini为原始默认配置,重新运行pip命令,它对我有用!

总结我的解决方案:

  1. 检查pip.ini(通常在path下C:\ProgramData\pip)是否已被修改;

  2. 如果在步骤1中为是,请尝试将其重置为默认配置。

I also hit this problem on my windows10 and tried all the answers but didn’t solve my problem.

C:\python367\Scripts>pip install Flask

Collecting Flask Could not find a version that satisfies the requirement Flask (from versions: ) No matching distribution found for Flask

After that, I find the pip configuration file had been modified. So, I set the pip.ini as the original default configuration, re-run the pip command and it works for me!

In summary of the solution of mine:

  1. Check the pip.ini (usually under the path C:\ProgramData\pip) had been modified;

  2. If yes in step1, try to reset it to a default configuration.


回答 14

或者只是所需的库不在存储库中。我是Python新手,关于升级pip的所有建议最终都被误导了。我只需要查看https://pypi.org/,发现该库(在我的情况下为气流)停在某个旧版本上,然后将其重命名。是的,愚蠢的解决方案也是可能的:-)。

Or simply the required library just isn’t in the repo. I’m Python newbie and all advices about upgrading pip finally shown as misleading. I had just to look into https://pypi.org/ , finding the library (airflow in my case) stopped at some old version, after which it was renamed. Yes, also that silly solution is also possible :-).


回答 15

对于所有python3pip3用户:

curl https://bootstrap.pypa.io/get-pip.py | sudo python3

然后假设您要安装熊猫

pip3 install pandas --user

For all the python3 and pip3 users out there:

curl https://bootstrap.pypa.io/get-pip.py | sudo python3

and then assume you want to install pandas

pip3 install pandas --user

回答 16

通过以下方式安装pip的答案:

  1. curl https://bootstrap.pypa.io/get-pip.py |sudo python 要么
  2. curl https://bootstrap.pypa.io/get-pip.py | python

由于我不断收到错误,因此对我不起作用:

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip

我必须pip通过以下方式手动安装:

  1. 前往pip发行网站
  2. 下载tar.gz版本
  3. 将文件解压缩到本地并cd进入目录
  4. python setup.py install

The answers of installing pip via:

  1. curl https://bootstrap.pypa.io/get-pip.py |sudo python or
  2. curl https://bootstrap.pypa.io/get-pip.py | python

did not work for me as I kept on getting the error:

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip

I had to install pip manually via:

  1. Go the pip distribution website
  2. Download the tar.gz version
  3. Unpack the file locally and cd into the directory
  4. run python setup.py install

重命名virtualenv文件夹而不破坏它

问题:重命名virtualenv文件夹而不破坏它

我已经创建了文件夹并在其中初始化了virtualenv实例。

$ mkdir myproject
$ cd myproject
$ virtualenv env

当我运行时(env)$ pip freeze,它将按原样显示已安装的软件包。

现在我想重命名myproject/project/

$ mv myproject/ project/

但是,当我跑步时

$ . env/bin/activate
(env)$ pip freeze

提示未安装pip。如何在不破坏环境的情况下重命名项目文件夹?

I’ve created folder and initialized a virtualenv instance in it.

$ mkdir myproject
$ cd myproject
$ virtualenv env

When I run (env)$ pip freeze, it shows the installed packages as it should.

Now I want to rename myproject/ to project/.

$ mv myproject/ project/

However, now when I run

$ . env/bin/activate
(env)$ pip freeze

it says pip is not installed. How do I rename the project folder without breaking the environment?


回答 0

您需要调整安装以使用相对路径。virtualenv为此提供了--relocatable选项。从文档

通常,环境绑定到特定路径。这意味着您无法移动环境或将其复制到另一台计算机。您可以使用以下命令修复环境以使其可重定位:

$ virtualenv-可重定位的ENV

注意: ENV是虚拟环境的名称,您必须从ENV目录外部运行它。

这将使setuptools创建的某些文件或分发文件的文件使用相对路径,并将所有脚本更改为使用activate_this.py而不是使用Python解释器的位置来选择环境。

注意:在将任何软件包安装到环境中之后,必须运行此命令。如果使环境可重定位,然后安装新软件包,则必须再次运行virtualenv –relocatable。

You need to adjust your install to use relative paths. virtualenv provides for this with the --relocatable option. From the docs:

Normally environments are tied to a specific path. That means that you cannot move an environment around or copy it to another computer. You can fix up an environment to make it relocatable with the command:

$ virtualenv –relocatable ENV

NOTE: ENV is the name of the virtual environment and you must run this from outside the ENV directory.

This will make some of the files created by setuptools or distribute use relative paths, and will change all the scripts to use activate_this.py instead of using the location of the Python interpreter to select the environment.

Note: you must run this after you’ve installed any packages into the environment. If you make an environment relocatable, then install a new package, you must run virtualenv –relocatable again.


回答 1

我相信“知道为什么”比“知道如何”更重要。因此,这是解决此问题的另一种方法。

运行时. env/bin/activate,它实际上执行以下命令(/tmp例如,使用):

VIRTUAL_ENV="/tmp/myproject/env"
export VIRTUAL_ENV

但是,您刚刚将重命名myprojectproject,因此该命令无法执行。这就是为什么这样说的原因pip is not installed,因为您尚未安装pip在系统全局环境中,并且您的virtualenv pip来源不正确。

如果要手动修复此问题,请采用以下方法:

  1. 使用您喜欢的Vim编辑器,/tmp/project/env/bin/activate通常在第42行进行修改:

    VIRTUAL_ENV='/tmp/myproject/env' => VIRTUAL_ENV='/tmp/project/env'

  2. /tmp/project/env/bin/pip在第1行中进行修改:

    #!/tmp/myproject/env/bin/python => #!/tmp/project/env/bin/python

之后,env再次激活您的虚拟环境,您将看到自己pip又回来了。

I believe “knowing why” matters more than “knowing how”. So, here is another approach to fix this.

When you run . env/bin/activate, it actually executes the following commands (using /tmp for example):

VIRTUAL_ENV="/tmp/myproject/env"
export VIRTUAL_ENV

However, you have just renamed myproject to project, so that command failed to execute. That is why it says pip is not installed, because you haven’t installed pip in the system global environment and your virtualenv pip is not sourced correctly.

If you want to fix this manually, this is the way:

  1. With your favorite editor like Vim, modify /tmp/project/env/bin/activate usually in line 42:

    VIRTUAL_ENV='/tmp/myproject/env' => VIRTUAL_ENV='/tmp/project/env'

  2. Modify /tmp/project/env/bin/pip in line 1:

    #!/tmp/myproject/env/bin/python => #!/tmp/project/env/bin/python

After that, activate your virtual environment env again, and you will see your pip has come back again.


回答 2

注意:作为@jb。指出,此解决方案仅适用于容易(重新)创建virtualenv的。如果环境需要花费几个小时来安装此解决方案,则不建议


Virtualenvs很棒,因为它们易于制作和切换。它们可以防止您陷入单一配置中。如果您知道项目要求或可以得到它们,请新建一个virtualenv

  • 建立requirements.txt档案

    (env)$ pip freeze > requirements.txt

    • 如果您无法创建requirements.txt文件,请env/lib/pythonX.X/site-packages在删除原始文件之前进行检查env
  • 删除现有的 (env)

    deactivate && rm -rf env

  • 创建一个新的virtualenv,激活它并安装需求

    virtualenv env && . env/bin/activate && pip install -r requirements.txt


或者,使用virtualenvwrapper使事情变得简单一些,因为所有virtualenv都保存在集中位置

$(old-venv) pip freeze > temp-reqs.txt
$(old-venv) deactivate
$ mkvirtualenv new-venv
$(new-venv) pip install -r temp-reqs.txt
$(new-venv) rmvirtualenv old-venv

NOTE: As @jb. points out, this solution only applies to easily (re)created virtualenvs. If an environment takes several hours to install this solution is not recommended


Virtualenvs are great because they are easy to make and switch around; they keep you from getting locked into a single configuration. If you know the project requirements, or can get them, Make a new virtualenv:

  • Create a requirements.txt file

    (env)$ pip freeze > requirements.txt

    • If you can’t create the requirements.txt file, check env/lib/pythonX.X/site-packages before removing the original env.
  • Delete the existing (env)

    deactivate && rm -rf env

  • Create a new virtualenv, activate it, and install requirements

    virtualenv env && . env/bin/activate && pip install -r requirements.txt


Alternatively, use virtualenvwrapper to make things a little easier as all virtualenvs are kept in a centralized location

$(old-venv) pip freeze > temp-reqs.txt
$(old-venv) deactivate
$ mkvirtualenv new-venv
$(new-venv) pip install -r temp-reqs.txt
$(new-venv) rmvirtualenv old-venv

回答 3

我总是安装virtualenvwrapper来提供帮助。在shell提示下:

pip install virtualenvwrapper

在virtualenvwrapper文档中有记录的方法-cpvirtualenv, 这就是您要做的。确保您不在环境中,然后返回到Shell提示符。输入所需名称:

cpvirtualenv oldenv newenv

然后,如有必要:

rmvirtualenv oldenv

要转到您的newenv,请执行以下操作:

workon newenv

I always install virtualenvwrapper to help out. From the shell prompt:

pip install virtualenvwrapper

There is a way documented in the virtualenvwrapper documents – cpvirtualenv This is what you do. Make sure you are out of your environment and back to the shell prompt. Type in this with the names required:

cpvirtualenv oldenv newenv

And then, if necessary:

rmvirtualenv oldenv

To go to your newenv:

workon newenv

回答 4

您可以按照以下步骤解决问题:

  1. 重命名目录
  2. 重新运行这个: $ virtualenv ..\path\renamed_directory
  3. virtualenv将纠正目录关联,同时将软件包保留在原位
  4. $ scripts/activate
  5. $ pip freeze 确认您的包裹到位
  6. 一个重要的警告,如果您在virtualenv目录中的脚本文件中有任何静态路径依赖项,则必须手动更改这些依赖项。

You can fix your issue by following these steps:

  1. rename your directory
  2. rerun this: $ virtualenv ..\path\renamed_directory
  3. virtualenv will correct the directory associations while leaving your packages in place
  4. $ scripts/activate
  5. $ pip freeze to verify your packages are in place
  6. An important caveat, if you have any static path dependencies in script files in your virtualenv directory, you will have to manually change those.

回答 5

对我来说很多次都没有问题的实现方法是virtualenv-clone

pip install virtualenv-clone
virtualenv-clone old-dir/env new-dir/env

Yet another way to do it that worked for me many times without problems is virtualenv-clone:

pip install virtualenv-clone
virtualenv-clone old-dir/env new-dir/env

回答 6

(在项目文件夹中)

cd bin
sed -i 's/old_dir_name/new_dir_name/g' *

不要忘记停用和激活

Run this inside your project folder:

cd bin
sed -i 's/old_dir_name/new_dir_name/g' *

Don’t forget to deactivate and activate.


回答 7

virtualenv --relocatable ENV这不是理想的解决方案。我认为大多数人都希望能够重命名virtualenv 而不会产生任何长期的副作用。

因此,我创建了一个简单的工具来执行此操作。virtualenv-mv的项目页面对它进行了更详细的概述,但是从本质上讲,您可以virtualenv-mv像使用简单的实现mv(没有任何选项)那样使用。

例如:

virtualenv-mv myproject project

但是请注意,我只是对此进行了修改。在异常情况下(例如,符号链接的virtualenvs)它可能会损坏,因此请小心(备份无法承受的损失),如果遇到任何问题,请告诉我。

virtualenv --relocatable ENV is not a desirable solution. I assume most people want the ability to rename a virtualenv without any long-term side effects.

So I’ve created a simple tool to do just that. The project page for virtualenv-mv outlines it in a bit more detail, but essentially you can use virtualenv-mv just like you’d use a simple implementation of mv (without any options).

For example:

virtualenv-mv myproject project

Please note however that I just hacked this up. It could break under unusual circumstances (e.g. symlinked virtualenvs) so please be careful (back up what you can’t afford to lose) and let me know if you encounter any problems.


如何离线安装软件包?

问题:如何离线安装软件包?

从pypi下载python软件包的最佳方法是什么,以便从另一台计算机上脱机安装?有什么简单的方法可以通过pip或easy_install来做到这一点?我正在尝试在未连接到Internet的FreeBSD盒上安装请求库。

What’s the best way to download a python package and it’s dependencies from pypi for offline installation on another machine? Is there any easy way to do this with pip or easy_install? I’m trying to install the requests library on a FreeBSD box that is not connected to the internet.


回答 0

如果该软件包位于PYPI上,则将其及其依赖项下载到某个本地目录。例如

$ mkdir / pypi && cd / pypi
$ ls -la
  -rw-r--r-- 1个Pavel人员237954 Apr 19 11:31 Flask-WTF-0.6.tar.gz
  -rw-r--r-- 1个Pavel员工389741 2月22日17:10 Jinja2-2.6.tar.gz
  -rw-r--r-- 1个Pavel人员70305 Apr 11 00:28 MySQL-python-1.2.3.tar.gz
  -rw-r--r-- 1个Pavel人员2597214 Apr 10 18:26 SQLAlchemy-0.7.6.tar.gz
  -rw-r--r-- 1个Pavel员工1108056 2月22日17:10 Werkzeug-0.8.2.tar.gz
  -rw-r--r-- 1个Pavel员工488207 Apr 10 18:26 boto-2.3.0.tar.gz
  -rw-r--r-- 1个Pavel人员490192 4月16日12:00 flask-0.9-dev-2a6c80a.tar.gz

某些软件包可能必须手工存档到外观相似的tarball中。当我想要某个东西的最新版本(不稳定)时,我会做很多事情。某些软件包不在PYPI上,因此也适用于它们。

假设您在中有一个格式正确的Python应用程序~/src/myapp~/src/myapp/setup.py将会install_requires列出您/pypi目录中的一或多个内容的列表。像这样:

  install_requires=[
    'boto',
    'Flask',
    'Werkzeug',
    # and so on

如果您希望能够在拥有所有必要依赖项的情况下运行您的应用程序,同时仍然对其进行黑客攻击,则可以执行以下操作:

$ cd〜/ src / myapp
$ python setup.py开发--always-unzip --allow-hosts = None --find-links = / pypi

这样,您的应用将直接从您的源目录执行。您可以破解某些东西,然后重新运行该应用程序而无需重建任何内容。

如果要将应用程序及其依赖项安装到当前的python环境中,请执行以下操作:

$ cd〜/ src / myapp
$ easy_install --always-unzip --allow-hosts = None --find-links = / pypi。

在这两种情况下,如果/pypi目录中不存在一个或多个依赖项,构建都将失败。它不会尝试从Internet混杂地安装丢失的东西。

我强烈建议在活动的虚拟环境中调用它setup.py develop ...,以避免污染全局Python环境。(virtualenv是)几乎可以走的路。切勿在全局Python环境中安装任何东西。easy_install ...

如果您构建了应用程序的计算机与要在其上部署应用程序的计算机具有相同的体系结构,则可以将所有easy_install内容都放入其中的整个虚拟环境目录中。不过,在压缩之前,您必须使虚拟环境目录可重定位(请参见 –relocatable选项)。注意:目标计算机需要安装相同版本的Python,并且应用程序可能也已经预安装了基于C的任何依赖关系(例如,如果您依赖PIL,那么必须预安装libpng,libjpeg等) 。

If the package is on PYPI, download it and its dependencies to some local directory. E.g.

$ mkdir /pypi && cd /pypi
$ ls -la
  -rw-r--r--   1 pavel  staff   237954 Apr 19 11:31 Flask-WTF-0.6.tar.gz
  -rw-r--r--   1 pavel  staff   389741 Feb 22 17:10 Jinja2-2.6.tar.gz
  -rw-r--r--   1 pavel  staff    70305 Apr 11 00:28 MySQL-python-1.2.3.tar.gz
  -rw-r--r--   1 pavel  staff  2597214 Apr 10 18:26 SQLAlchemy-0.7.6.tar.gz
  -rw-r--r--   1 pavel  staff  1108056 Feb 22 17:10 Werkzeug-0.8.2.tar.gz
  -rw-r--r--   1 pavel  staff   488207 Apr 10 18:26 boto-2.3.0.tar.gz
  -rw-r--r--   1 pavel  staff   490192 Apr 16 12:00 flask-0.9-dev-2a6c80a.tar.gz

Some packages may have to be archived into similar looking tarballs by hand. I do it a lot when I want a more recent (less stable) version of something. Some packages aren’t on PYPI, so same applies to them.

Suppose you have a properly formed Python application in ~/src/myapp. ~/src/myapp/setup.py will have install_requires list that mentions one or more things that you have in your /pypi directory. Like so:

  install_requires=[
    'boto',
    'Flask',
    'Werkzeug',
    # and so on

If you want to be able to run your app with all the necessary dependencies while still hacking on it, you’ll do something like this:

$ cd ~/src/myapp
$ python setup.py develop --always-unzip --allow-hosts=None --find-links=/pypi

This way your app will be executed straight from your source directory. You can hack on things, and then rerun the app without rebuilding anything.

If you want to install your app and its dependencies into the current python environment, you’ll do something like this:

$ cd ~/src/myapp
$ easy_install --always-unzip --allow-hosts=None --find-links=/pypi .

In both cases, the build will fail if one or more dependencies aren’t present in /pypi directory. It won’t attempt to promiscuously install missing things from Internet.

I highly recommend to invoke setup.py develop ... and easy_install ... within an active virtual environment to avoid contaminating your global Python environment. It is (virtualenv that is) pretty much the way to go. Never install anything into global Python environment.

If the machine that you’ve built your app has same architecture as the machine on which you want to deploy it, you can simply tarball the entire virtual environment directory into which you easy_install-ed everything. Just before tarballing though, you must make the virtual environment directory relocatable (see –relocatable option). NOTE: the destination machine needs to have the same version of Python installed, and also any C-based dependencies your app may have must be preinstalled there too (e.g. say if you depend on PIL, then libpng, libjpeg, etc must be preinstalled).


回答 1

pip download命令使您无需安装即可下载软件包:

pip download -r requirements.txt

(在以前的pip版本中,拼写为 pip install --download -r requirements.txt。)

然后,您可以使用它们pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt来安装那些下载的sdist,而无需访问网络。

The pip download command lets you download packages without installing them:

pip download -r requirements.txt

(In previous versions of pip, this was spelled pip install --download -r requirements.txt.)

Then you can use pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt to install those downloaded sdists, without accessing the network.


回答 2

如果要脱机安装python库及其依赖项,请在具有相同操作系统,网络连接和python安装的机器上完成以下步骤:

1)创建一个requirements.txt内容相似的文件(注意-这些是您要下载的库):

Flask==0.12
requests>=2.7.0
scikit-learn==0.19.1
numpy==1.14.3
pandas==0.22.0

创建需求文件的一种方法是使用pip freeze > requirements.txt。这将列出您环境中的所有库。那你可以进去requirements.txt并删除不需要的对象。

2)执行命令 mkdir wheelhouse && pip download -r requirements.txt -d wheelhouse以将库及其依赖项下载到目录wheelhouse

3)将requirements.txt复制到 wheelhouse目录中

4)存档驾驶室成wheelhouse.tar.gztar -zcf wheelhouse.tar.gz wheelhouse

然后上传wheelhouse.tar.gz到目标计算机:

1)执行tar -zxf wheelhouse.tar.gz以提取文件

2)执行pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouse以安装库及其依赖项

If you want install python libs and their dependencies offline, finish following these steps on a machine with the same os, network connected, and python installed:

1) Create a requirements.txt file with similar content (Note – these are the libraries you wish to download):

Flask==0.12
requests>=2.7.0
scikit-learn==0.19.1
numpy==1.14.3
pandas==0.22.0

One option for creating the requirements file is to use pip freeze > requirements.txt. This will list all libraries in your environment. Then you can go in to requirements.txt and remove un-needed ones.

2) Execute command mkdir wheelhouse && pip download -r requirements.txt -d wheelhouse to download libs and their dependencies to directory wheelhouse

3) Copy requirements.txt into wheelhouse directory

4) Archive wheelhouse into wheelhouse.tar.gz with tar -zcf wheelhouse.tar.gz wheelhouse

Then upload wheelhouse.tar.gz to your target machine:

1) Execute tar -zxf wheelhouse.tar.gz to extract the files

2) Execute pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouse to install the libs and their dependencies


回答 3

离线python。为此,我使用virtualenv(隔离的Python环境)

1)使用pip在线安装virtualenv:

pip install virtualenv --user

或使用whl脱机:转到此链接,下载最新版本(.whl或tar.gz),然后使用以下命令进行安装:

pip install virtualenv-15.1.0-py2.py3-none-any.whl --user

通过使用--user您不需要使用sudo pip…

2)使用virtualenv

在联机计算机上,选择带有终端的目录cd并运行以下代码:

python -m virtualenv myenv
cd myenv
source bin/activate
pip install Flask

安装所有软件包后,必须requirements.txt在virtualenv处于活动状态时生成一个,以便

pip freeze > requirements.txt

打开一个新终端并创建另一个env之类的myenv2

python -m virtualenv myenv2
cd myenv2
source bin/activate
cd -
ls

现在,您可以转到您的requirements.txttranferred_packages文件夹所在的脱机文件夹。使用以下代码下载软件包,并将其全部放入tranferred_packages文件夹。

pip download -r requirements.txt

将您的脱机文件夹移至脱机计算机,然后

python -m virtualenv myenv2
cd myenv2
source bin/activate
cd -
cd offline
pip install --no-index --find-links="./tranferred_packages" -r requirements.txt

离线文件夹中的内容[requirements.txt,tranferred_pa​​ckages {Flask-0.10.1.tar.gz,…}]

检查包裹清单

pip list

注意:与2017年一样,最好使用python3。您可以使用此命令创建python 3 virtualenv。

virtualenv -p python3 envname

offline python. for doing this I use virtualenv (isolated Python environment)

1) install virtualenv online with pip:

pip install virtualenv --user

or offline with whl: go to this link , download last version (.whl or tar.gz) and install that with this command:

pip install virtualenv-15.1.0-py2.py3-none-any.whl --user

by using --user you don’t need to use sudo pip….

2) use virtualenv

on online machine select a directory with terminal cd and run this code:

python -m virtualenv myenv
cd myenv
source bin/activate
pip install Flask

after installing all the packages, you have to generate a requirements.txt so while your virtualenv is active, write

pip freeze > requirements.txt

open a new terminal and create another env like myenv2.

python -m virtualenv myenv2
cd myenv2
source bin/activate
cd -
ls

now you can go to your offline folder where your requirements.txt and tranferred_packages folder are in there. download the packages with following code and put all of them to tranferred_packages folder.

pip download -r requirements.txt

take your offline folder to offline computer and then

python -m virtualenv myenv2
cd myenv2
source bin/activate
cd -
cd offline
pip install --no-index --find-links="./tranferred_packages" -r requirements.txt

what is in the folder offline [requirements.txt , tranferred_packages {Flask-0.10.1.tar.gz, …}]

check list of your package

pip list

note: as we are in 2017 it is better to use python 3. you can create python 3 virtualenv with this command.

virtualenv -p python3 envname

回答 4

下载压缩包,将其转移到您的FreeBSD机器上并解压缩,然后运行python setup.py install就可以了!

编辑:只是要补充一点,您现在也可以使用pip安装tarball。

Download the tarball, transfer it to your FreeBSD machine and extract it, afterwards run python setup.py install and you’re done!

EDIT: Just to add on that, you can also install the tarballs with pip now.


回答 5

让我一步一步地完成该过程:

  1. 在连接到互联网的计算机上,创建一个文件夹。
   $ mkdir packages
   $ cd packages
  1. 打开命令提示符或shell并执行以下命令:

    假设您想要的软件包是 tensorflow

    $ pip download tensorflow

  2. 现在,在目标计算机上,复制packages文件夹并应用以下命令

  $ cd packages
  $ pip install 'tensorflow-xyz.whl' --no-index --find-links '.'

请注意,tensorflow-xyz.whl必须将替换为所需软件包的原始名称。

Let me go through the process step by step:

  1. On a computer connected to the internet, create a folder.
   $ mkdir packages
   $ cd packages
  1. open up a command prompt or shell and execute the following command:

    Suppose the package you want is tensorflow

    $ pip download tensorflow

  2. Now, on the target computer, copy the packages folder and apply the following command

  $ cd packages
  $ pip install 'tensorflow-xyz.whl' --no-index --find-links '.'

Note that the tensorflow-xyz.whl must be replaced by the original name of the required package.


回答 6

使用wheel编译包。

打包:

$ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
$ pip wheel -r requirements.txt --wheel-dir=$tempdir
$ cwd=`pwd`
$ (cd "$tempdir"; tar -cjvf "$cwd/bundled.tar.bz2" *)

复制tarball并安装:

$ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
$ (cd $tempdir; tar -xvf /path/to/bundled.tar.bz2)
$ pip install --force-reinstall --ignore-installed --upgrade --no-index --no-deps $tempdir/*

注意wheel二进制软件包不是跨机器的。

更多参考 此处:https : //pip.pypa.io/en/stable/user_guide/#installation-bundles

Using wheel compiled packages.

bundle up:

$ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
$ pip wheel -r requirements.txt --wheel-dir=$tempdir
$ cwd=`pwd`
$ (cd "$tempdir"; tar -cjvf "$cwd/bundled.tar.bz2" *)

copy tarball and install:

$ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
$ (cd $tempdir; tar -xvf /path/to/bundled.tar.bz2)
$ pip install --force-reinstall --ignore-installed --upgrade --no-index --no-deps $tempdir/*

Note wheel binary packages are not across machines.

More ref. here: https://pip.pypa.io/en/stable/user_guide/#installation-bundles


回答 7

我有一个类似的问题。而且我必须以相同的方式安装它,我们是从pypi安装的。

我做了以下事情:

  1. 创建一个目录以存储机器中所有可以访问Internet的软件包。

    mkdir -p /path/to/packages/
  2. 将所有软件包下载到路径

    pip download -r requirements.txt -d /path/to/packages
    
    Eg:- ls /root/wheelhouse/  # **/root/wheelhouse** is my **/path/to/packages/**
    total 4524
    -rw-r--r--. 1 root root   16667 May 23  2017 incremental-17.5.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   34713 Sep  1 10:21 attrs-18.2.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root 3088398 Oct 15 14:41 Twisted-18.9.0.tar.bz2
    -rw-r--r--. 1 root root  133356 Jan 28 15:58 chardet-3.0.4-py2.py3-none-any.whl
    -rw-r--r--. 1 root root  154154 Jan 28 15:58 certifi-2018.11.29-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   57987 Jan 28 15:58 requests-2.21.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   58594 Jan 28 15:58 idna-2.8-py2.py3-none-any.whl
    -rw-r--r--. 1 root root  118086 Jan 28 15:59 urllib3-1.24.1-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   47229 Jan 28 15:59 tqdm-4.30.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root    7922 Jan 28 16:13 constantly-15.1.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root  164706 Jan 28 16:14 zope.interface-4.6.0-cp27-cp27mu-manylinux1_x86_64.whl
    -rw-r--r--. 1 root root  573841 Jan 28 16:14 setuptools-40.7.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   37638 Jan 28 16:15 Automat-0.7.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   37905 Jan 28 16:15 hyperlink-18.0.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   52311 Jan 28 16:15 PyHamcrest-1.9.0-py2.py3-none-any.whl
    -rw-r--r--. 1 root root   10586 Jan 28 16:15 six-1.12.0-py2.py3-none-any.whl
  3. 压缩软件包目录,然后将其复制到没有Internet访问权限的计算机上。然后做,

    cd /path/to/packages/
    tar -cvzf packages.tar.gz .  # not the . (dot) at the end

    packages.tar.gz复制到没有Internet访问权限的目标计算机中。

  4. 在无法访问互联网的计算机上,执行以下操作(假设您将已解压缩的软件包复制到当前计算机上的/ path / to / package /中)

    cd /path/to/packages/
    tar -xvzf packages.tar.gz
    mkdir -p $HOME/.config/pip/
    
    vi $HOME/.config/pip/pip.conf

    并将以下内容粘贴并保存。

    [global]
    timeout = 10
    find-links = file:///path/to/package/
    no-cache-dir = true
    no-index = true
  5. 最后,我建议您使用某种形式的virtualenv安装软件包。

    virtualenv -p python2 venv # use python3, if you are on python3
    source ./venv/bin/activate
    pip install <package>

您应该能够下载目录/ path / to / package /中的所有模块。

注意:我只是这样做,因为我无法添加选项或更改我们安装模块的方式。不然我会做的

    pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt

I had a similar problem. And i had to make it install the same way, we do from pypi.

I did the following things:

  1. Make a directory to store all the packages in the machine that have internet access.

    mkdir -p /path/to/packages/
    
  2. Download all the packages to the path

Edit: You can also try:

python3 -m pip wheel --no-cache-dir -r requirements.txt -w /path/to/packages
pip download -r requirements.txt -d /path/to/packages

Eg:- ls /root/wheelhouse/  # **/root/wheelhouse** is my **/path/to/packages/**
total 4524
-rw-r--r--. 1 root root   16667 May 23  2017 incremental-17.5.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root   34713 Sep  1 10:21 attrs-18.2.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 3088398 Oct 15 14:41 Twisted-18.9.0.tar.bz2
-rw-r--r--. 1 root root  133356 Jan 28 15:58 chardet-3.0.4-py2.py3-none-any.whl
-rw-r--r--. 1 root root  154154 Jan 28 15:58 certifi-2018.11.29-py2.py3-none-any.whl
-rw-r--r--. 1 root root   57987 Jan 28 15:58 requests-2.21.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root   58594 Jan 28 15:58 idna-2.8-py2.py3-none-any.whl
-rw-r--r--. 1 root root  118086 Jan 28 15:59 urllib3-1.24.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root   47229 Jan 28 15:59 tqdm-4.30.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root    7922 Jan 28 16:13 constantly-15.1.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root  164706 Jan 28 16:14 zope.interface-4.6.0-cp27-cp27mu-manylinux1_x86_64.whl
-rw-r--r--. 1 root root  573841 Jan 28 16:14 setuptools-40.7.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root   37638 Jan 28 16:15 Automat-0.7.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root   37905 Jan 28 16:15 hyperlink-18.0.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root   52311 Jan 28 16:15 PyHamcrest-1.9.0-py2.py3-none-any.whl
 -rw-r--r--. 1 root root   10586 Jan 28 16:15 six-1.12.0-py2.py3-none-any.whl
  1. Tar the packages directory and copy it to the Machine that doesn’t have internet access. Then do,

    cd /path/to/packages/
    tar -cvzf packages.tar.gz .  # not the . (dot) at the end
    

Copy the packages.tar.gz into the destination machine that doesn’t have internet access.

  1. In the machine that doesn’t have internet access, do the following (Assuming you copied the tarred packages to /path/to/package/ in the current machine)

    cd /path/to/packages/
    tar -xvzf packages.tar.gz
    mkdir -p $HOME/.config/pip/
    vi $HOME/.config/pip/pip.conf
    

and paste the following content inside and save it.

[global]
timeout = 10
find-links = file:///path/to/package/
no-cache-dir = true
no-index = true
  1. Finally, i suggest you use, some form of virtualenv for installing the packages.

    virtualenv -p python2 venv # use python3, if you are on python3
    source ./venv/bin/activate
    pip install <package>
    

You should be able to download all the modules that are in the directory /path/to/package/.

Note: I only did this, because i couldn’t add options or change the way we install the modules. Otherwise i’d have done

pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt

回答 8

对于Pip 8.1.2,您可以用于pip download -r requ.txt将软件包下载到本地计算机。

For Pip 8.1.2 you can use pip download -r requ.txt to download packages to your local machine.


使用pip安装SciPy和NumPy

问题:使用pip安装SciPy和NumPy

我正在尝试在要分发的程序包中创建所需的库。它需要SciPyNumPy库。在开发过程中,我同时使用

apt-get install scipy

它安装了SciPy 0.9.0和NumPy 1.5.1,并且运行良好。

我想使用pip install– 做同样的事情,以便能够在我自己的包的setup.py中指定依赖项。

问题是,当我尝试:

pip install 'numpy==1.5.1'

它工作正常。

但是之后

pip install 'scipy==0.9.0'

惨败

raise self.notfounderror(self.notfounderror.__doc__)

numpy.distutils.system_info.BlasNotFoundError:

Blas (http://www.netlib.org/blas/) libraries not found.

Directories to search for the libraries can be specified in the

numpy/distutils/site.cfg file (section [blas]) or by setting

the BLAS environment variable.

我该如何工作?

I’m trying to create required libraries in a package I’m distributing. It requires both the SciPy and NumPy libraries. While developing, I installed both using

apt-get install scipy

which installed SciPy 0.9.0 and NumPy 1.5.1, and it worked fine.

I would like to do the same using pip install – in order to be able to specify dependencies in a setup.py of my own package.

The problem is, when I try:

pip install 'numpy==1.5.1'

it works fine.

But then

pip install 'scipy==0.9.0'

fails miserably, with

raise self.notfounderror(self.notfounderror.__doc__)

numpy.distutils.system_info.BlasNotFoundError:

Blas (http://www.netlib.org/blas/) libraries not found.

Directories to search for the libraries can be specified in the

numpy/distutils/site.cfg file (section [blas]) or by setting

the BLAS environment variable.

How do I get it to work?


回答 0

我假设我的回答是Linux经验。我发现pip install scipy要顺利进行有三个先决条件。

转到此处:安装SciPY

按照说明下载,构建和导出BLAS的env变量,然后下载LAPACK。注意不要盲目剪切’n’粘贴shell命令-您需要根据您的体系结构等选择几行,并且您需要修复/添加错误地假定为的正确目录好。

您可能需要做的第三件事是yum安装numpy-f2py或等效程序。

哦,是的,最后,您可能需要安装gcc-gfortran,因为上述库都是Fortran源码。

I am assuming Linux experience in my answer; I found that there are three prerequisites to getting pip install scipy to proceed nicely.

Go here: Installing SciPY

Follow the instructions to download, build and export the env variable for BLAS and then LAPACK. Be careful to not just blindly cut’n’paste the shell commands – there will be a few lines you need to select depending on your architecture, etc., and you’ll need to fix/add the correct directories that it incorrectly assumes as well.

The third thing you may need is to yum install numpy-f2py or the equivalent.

Oh, yes and lastly, you may need to yum install gcc-gfortran as the libraries above are Fortran source.


回答 1

这在Ubuntu 14.04上对我有用:

sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev gfortran
pip install scipy

This worked for me on Ubuntu 14.04:

sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev gfortran
pip install scipy

回答 2

如果使用的是Ubuntu,则需要libblas和liblapack开发软件包。

aptitude install libblas-dev liblapack-dev
pip install scipy

you need the libblas and liblapack dev packages if you are using Ubuntu.

aptitude install libblas-dev liblapack-dev
pip install scipy

回答 3

由于先前使用yum进行安装的说明已被破坏,因此这里提供了在诸如fedora之类的设备上进行安装的更新说明。我已经在“ Amazon Linux AMI 2016.03”上对此进行了测试

sudo yum install atlas-devel lapack-devel blas-devel libgfortran
pip install scipy

Since the previous instructions for installing with yum are broken here are the updated instructions for installing on something like fedora. I’ve tested this on “Amazon Linux AMI 2016.03”

sudo yum install atlas-devel lapack-devel blas-devel libgfortran
pip install scipy

回答 4

我当时正在从事一个依赖于numpy和scipy的项目。在Fedora 23的全新安装中,使用适用于Python 3.4的python虚拟环境(也适用于Python 2.7),并在setup.py中使用以下内容(在setup()方法中)

setup_requires=[
    'numpy',
],
install_requires=[
    'numpy',
    'scipy',
],

我发现必须运行以下命令才能pip install -e .开始工作:

pip install --upgrade pip

sudo dnf install atlas-devel gcc-{c++,gfortran} subversion redhat-rpm-config

redhat-rpm-config是SciPy的的使用redhat-hardened-cc1,而不是常规cc1

I was working on a project that depended on numpy and scipy. In a clean installation of Fedora 23, using a python virtual environment for Python 3.4 (also worked for Python 2.7), and with the following in my setup.py (in the setup() method)

setup_requires=[
    'numpy',
],
install_requires=[
    'numpy',
    'scipy',
],

I found I had to run the following to get pip install -e . to work:

pip install --upgrade pip

and

sudo dnf install atlas-devel gcc-{c++,gfortran} subversion redhat-rpm-config

The redhat-rpm-config is for scipy’s use of redhat-hardened-cc1 as opposed to the regular cc1


回答 5

Windows python 3.5上,我设法scipy使用conda not 进行安装pip

conda install scipy

On windows python 3.5, I managed to install scipy by using conda not pip:

conda install scipy

回答 6

这是什么操作系统?答案可能取决于所涉及的操作系统。但是,您似乎需要找到此BLAS库并进行安装。它似乎不在PIP中(因此您必须手工完成),但是如果您安装它,则应该让您进行SciPy安装。

What operating system is this? The answer might depend on the OS involved. However, it looks like you need to find this BLAS library and install it. It doesn’t seem to be in PIP (you’ll have to do it by hand thus), but if you install it, it ought let you progress your SciPy install.


回答 7

就我而言,升级点可以解决问题。另外,我已经用-U参数安装了scipy(将所有软件包升级到最新的可用版本)

in my case, upgrading pip did the trick. Also, I’ve installed scipy with -U parameter (upgrade all packages to the last available version)


pip安装:请检查该目录的权限和所有者

问题:pip安装:请检查该目录的权限和所有者

在安装pip和python时,我遇到了一个提示:

目录“ / Users / Parthenon / Library / Logs / pi”或其父目录不属于当前用户,并且调试日志已禁用。请检查该目录的权限和所有者。如果使用sudo执行pip,则可能需要-H标志。

因为我现在必须使用安装sudo

我的Mac上已经安装了python和一些库,我正在运行Yosemite。最近,我不得不进行彻底擦拭,然后重新安装操作系统。现在,我收到此提示,并且在弄清楚如何更改它时遇到了麻烦

我的命令行是以前Parthenon$,现在是Philips-MBP:~ Parthenon$

我是这台计算机的唯一所有者,这是计算机上的唯一帐户。升级到python 3.4时,这似乎是个问题,似乎什么都没在正确的地方,virtualenv不会到达我期望的位置,等等。

While installing pip and python I have ran into a that says:

The directory ‘/Users/Parthenon/Library/Logs/pi’ or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.

because I now have to install using sudo.

I had python and a handful of libraries already installed on my Mac, I’m running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I’m getting this prompt and I’m having trouble figuring out how to change it

Before my command line was Parthenon$ now it’s Philips-MBP:~ Parthenon$

I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn’t going where I expect it to, etc.


回答 0

从运行pip到Windows时,我在Mac上也看到了这种变化sudo pip。添加-H到sudo会使该消息对我消失。例如

sudo -H pip install foo

man sudo告诉我-H原因sudo设置$HOME为目标用户(在这种情况下为root)。

因此,似乎pip正在调查,$HOME/Library/Log并且sudo默认情况下未将其设置$HOME/root/。毫不奇怪~/Library/Log,您是用户而不是root。

我怀疑这是最近的点差变化。我现在将其运行sudo -H以解决该问题。

I also saw this change on my Mac when I went from running pip to sudo pip. Adding -H to sudo causes the message to go away for me. E.g.

sudo -H pip install foo

man sudo tells me that -H causes sudo to set $HOME to the target users (root in this case).

So it appears pip is looking into $HOME/Library/Log and sudo by default isn’t setting $HOME to /root/. Not surprisingly ~/Library/Log is owned by you as a user rather than root.

I suspect this is some recent change in pip. I’ll run it with sudo -H for now to work around.


回答 1

这里的问题是,您以某种方式将其安装到virtualenv中sudo。可能是偶然的。这意味着root用户将重写Python软件包数据,从而使所有文件均由root拥有,而您的普通用户将无法再写入这些文件。通常,virtualenv仅应由普通的UNIX用户使用和拥有。

您可以通过将UNIX文件权限包更改为用户来解决此问题。尝试:

$ sudo chown -R USERNAME /Users/USERNAME/Library/Logs/pip
$ sudo chown -R USERNAME /Users/USERNAME/Library/Caches/pip

然后pip应该能够再次写入这些文件。

有关UNIX文件权限管理的更多信息

What is the problem here is that you somehow installed into virtualenv using sudo. Probably by accident. This means root user will rewrite Python package data, making all file owned by root and your normal user cannot write those files anymore. Usually virtualenv should be used and owned by your normal UNIX user only.

You can fix the issue by changing UNIX file permissions pack to your user. Try:

$ sudo chown -R USERNAME /Users/USERNAME/Library/Logs/pip
$ sudo chown -R USERNAME /Users/USERNAME/Library/Caches/pip

then pip should be able to write those files again.

More information about UNIX file permission management


回答 2

pip install --user <package name> (无需sudo)为我解决了一个非常类似的问题。

pip install --user <package name> (no sudo needed) worked for me for a very similar problem.


回答 3

基本信息

  • 系统:mac os 18.0.0
  • 当前用户:yutou

钥匙

  1. 将当前帐户添加到车轮组
sudo dscl . -append /Groups/wheel wheel $(whoami)
  1. 将python封装模式修改为775。
chmod -R 775 ${this_is_your_python_package_path}

整个东西

  • 当python3编译良好时,信息就像问题所言。
  • 我尝试使用pip3 install requests并得到:
File "/usr/local/python3/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 
'/usr/local/python3/lib/python3.6/site-packages/requests'
  • 所以我cd /usr/local/python3/lib/python3.6/site-packages,然后ls -al得到:
drwxr-xr-x    6 root   wheel   192B  2 27 18:06 requests/

当我看到此消息时,我了解到,makedirs是写操作,但是drwxrwxr-x只有用户root才能显示的请求模式才能写入请求文件。如果将yutou(whoami)添加到组合轮,然后将包修改为组合轮可以写,那么我可以写,并且问题解决了。

如何在组轮中添加yutou?+检测车轮sudo dscl . -list /groups GroupMembership,,您会发现:

wheel                    root

小组轮只有一个成员根。+将yutou添加到分组轮,sudo dscl . -append /Groups/wheel wheel yutou。+检查sudo dscl . -list /groups GroupMembership

wheel                    root yutou

修改python包模式

chmod -R 775 /usr/local/python3/lib/python3.6

basic info

  • system: mac os 18.0.0
  • current user: yutou

the key

  1. add the current account to wheel group
sudo dscl . -append /Groups/wheel wheel $(whoami)
  1. modify python package mode to 775.
chmod -R 775 ${this_is_your_python_package_path}

the whole thing

  • when python3 compiled well, the infomation is just like the question said.
  • I try to use pip3 install requests and got:
File "/usr/local/python3/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 
'/usr/local/python3/lib/python3.6/site-packages/requests'
  • so i cd /usr/local/python3/lib/python3.6/site-packages, then ls -al and got:
drwxr-xr-x    6 root   wheel   192B  2 27 18:06 requests/

when i saw this, i understood, makedirs is an action of write, but the requests mode drwxrwxr-x displaied only user root can write the requests file. If add yutou(whoami) to the group wheel, and modify the package to the group wheel can write, then i can write, and the problem solved.

How to add yutou to group wheel? + detect group wheel, sudo dscl . -list /groups GroupMembership, you will find:

wheel                    root

the group wheel only one member root. + add yutou to group wheel, sudo dscl . -append /Groups/wheel wheel yutou. + check, sudo dscl . -list /groups GroupMembership:

wheel                    root yutou

modify the python package mode

chmod -R 775 /usr/local/python3/lib/python3.6

回答 4

如果您更改了$ PATH变量,也可能会导致问题。如果您认为可能是问题所在,请检查〜/ .bash_profile或〜/ .bashrc

If you altered your $PATH variable that could also cause the problem. If you think that might be the issue, check your ~/.bash_profile or ~/.bashrc


我可以在点子要求文件中添加注释吗?

问题:我可以在点子要求文件中添加注释吗?

我想在点子要求文件中添加一些包装的注释。(只是为了解释为什么该软件包在列表中。)我可以这样做吗?

我在想像

Babel==0.9.5 # translation
CherryPy==3.2.0 # web server
Creoleparser==0.7.1 # wiki formatting
Genshi==0.5.1 # templating

I’d like to add comments for a few packages in a pip requirements file. (Just to explain why that package is on the list.) Can I do this?

I’m imagining something like

Babel==0.9.5 # translation
CherryPy==3.2.0 # web server
Creoleparser==0.7.1 # wiki formatting
Genshi==0.5.1 # templating

回答 0

当然可以,只需使用 #

pipdocs

以#开头的行被视为注释并被忽略。空格后跟#会导致#和该行的其余部分被视为注释。

Sure, you can, just use #

pip docs:

A line that begins with # is treated as a comment and ignored. Whitespace followed by a # causes the # and the remainder of the line to be treated as a comment.


回答 1


使用“ pip”卸载软件包还会删除相关软件包吗?

问题:使用“ pip”卸载软件包还会删除相关软件包吗?

当您pip用来安装软件包时,所有必需的软件包也会随之安装(依赖关系)。卸载该软件包还会删除从属软件包吗?

When you use pip to install a package, all the required packages will also be installed with it (dependencies). Does uninstalling that package also remove the dependent packages?


回答 0

不,它不会卸载依赖包。它仅删除指定的软件包:

$ pip install specloud
$ pip freeze # all the packages here are dependencies of specloud package

figleaf == 0.6.1
鼻子== 1.1.2
pinocchio == 0.3
specloud == 0.4.5

$ pip uninstall specloud
$ pip freeze

figleaf == 0.6.1
鼻子== 1.1.2
匹诺曹== 0.3

如您所见,这些程序包是来自的依赖项specloud,它们仍然存在,但不是specloud程序包本身。

如下所述,您可以安装并使用pip-autoremove实用程序删除软件包以及未使用的依赖项。

No, it doesn’t uninstall the dependencies packages. It only removes the specified package:

$ pip install specloud
$ pip freeze # all the packages here are dependencies of specloud package

figleaf==0.6.1
nose==1.1.2
pinocchio==0.3
specloud==0.4.5

$ pip uninstall specloud
$ pip freeze

figleaf==0.6.1
nose==1.1.2
pinocchio==0.3

As you can see those packages are dependencies from specloud and they’re still there, but not the specloud package itself.

As mentioned below, You can install and use the pip-autoremove utility to remove a package plus unused dependencies.


回答 1

您可以安装并使用pip-autoremove实用程序删除软件包以及未使用的依赖项。

# install pip-autoremove
pip install pip-autoremove
# remove "somepackage" plus its dependencies:
pip-autoremove somepackage -y

You can install and use the pip-autoremove utility to remove a package plus unused dependencies.

# install pip-autoremove
pip install pip-autoremove
# remove "somepackage" plus its dependencies:
pip-autoremove somepackage -y

回答 2

我已经使用以下bash行成功删除了软件包的依赖项:

for dep in $(pip show somepackage | grep Requires | sed 's/Requires: //g; s/,//g') ; do pip uninstall -y $dep ; done

这在pip 1.5.4上有效

i’ve successfully removed dependencies of a package using this bash line:

for dep in $(pip show somepackage | grep Requires | sed 's/Requires: //g; s/,//g') ; do pip uninstall -y $dep ; done

this worked on pip 1.5.4


回答 3

我发现了解决方案,尽管对于某些人来说可能有点困难。

第一步(适用于python3和linux):
pip3 install pip-autoremove
第二步:
cd /home/usernamegoeshere/.local/bin/
第三步:
gedit /home/usernamegoeshere/.local/lib/python3.8/site-packages/ pip_autoremove.py
并将所有pip更改为pip3第四步:./ pip-autoremove packagenamegoeshere

至少,这是对我有用的…

I have found the solution even though it might be a little difficult for some to carry out.

1st step (for python3 and linux):
pip3 install pip-autoremove
2nd step:
cd /home/usernamegoeshere/.local/bin/
3rd step:
gedit /home/usernamegoeshere/.local/lib/python3.8/site-packages/pip_autoremove.py
and change all pip(s) to pip3 4th step: ./pip-autoremove packagenamegoeshere

At least, this was what worked for me …


回答 4

您可以尝试使用https://github.com/cls1991/pef。它将删除软件包及其所有依赖项。

You may have a try for https://github.com/cls1991/pef. It will remove package with its all dependencies.


如何在Mac上安装pip3?

问题:如何在Mac上安装pip3?

我正在尝试安装pip3,但没有任何运气。此外,我尝试了sudo install,但没有成功。如何在Mac上安装pip3?

sudo easy_install pip3
Password:
Searching for pip3
Reading https://pypi.python.org/simple/pip3/
Couldn't find index page for 'pip3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/

No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse('pip3')

I’m trying to install pip3, but I’m not having any luck. Also, I tried sudo install and it did not work. How could I install pip3 on my Mac?

sudo easy_install pip3
Password:
Searching for pip3
Reading https://pypi.python.org/simple/pip3/
Couldn't find index page for 'pip3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/

No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse('pip3')

回答 0

更新-1.5之后的自制版本

根据官方的Homebrew页面

在2018年3月1日,python公式将升级到Python 3.x,并且将添加python @ 2公式以安装Python 2.7(尽管这仅是小桶,因此默认情况下python和python2都不会添加到PATH中,而无需手动冲泡链接–force)。我们将维护python2,python3和python @ 3别名。

因此,要安装Python 3,请运行以下命令:

brew install python3

然后,pippip3会自动安装,您可以通过安装任何软件包pip install <package>


旧版本的Homebrew

不仅brew install python3而且brew postinstall python3

因此,您必须运行:

brew install python3
brew postinstall python3

请注意,您应该检查控制台,因为它可能会导致您出错,并且在这种情况下,pip3不会安装。

UPDATED – Homebrew version after 1.5

According to the official Homebrew page:

On 1st March 2018 the python formula will be upgraded to Python 3.x and a python@2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link –force). We will maintain python2, python3 and python@3 aliases.

So to install Python 3, run the following command:

brew install python3

Then, the pip or pip3 is installed automatically, and you can install any package by pip install <package>.


The older version of Homebrew

Not only brew install python3 but also brew postinstall python3

So you must run:

brew install python3
brew postinstall python3

Note that you should check the console, as it might get you errors and in that case, the pip3 is NOT installed.


回答 1

你可以用 自制的

然后运行:

brew install python3

You could use home-brew

Then just run:

brew install python3

回答 2

我用以下命令解决了相同的问题:

curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

I solved the same problem with these commands:

curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

回答 3

对我来说brew postinstall python3没用。在GitHub自制问题页面上找到了此解决方案:

$ brew rm python 
$ rm -rf /usr/local/opt/python
$ brew cleanup 
$ brew install python3

For me brew postinstall python3 didn’t work. Found this solution on GitHub homebrew issues page:

$ brew rm python 
$ rm -rf /usr/local/opt/python
$ brew cleanup 
$ brew install python3

回答 4

Python3成功运行,但没有pip3。尝试了许多来自stackoverflow,quora等的建议。(大量安装和卸载)

Python3总是很好,但是没有pip3。最后,我从以下网址下载了Python3:https://www.python.org/downloads/

只需单击鼠标,一切(Python3 + pip3)现在都可以正常工作。

Python3 was working successfully but without pip3. Tried many advises from stackoverflow, quora and others. (numerous installs and uninstalls)

Python3 was always fine but without pip3. Finally I downloaded Python3 from: https://www.python.org/downloads/

By simple mouse clicks and everything (Python3 + pip3) is working fine now.


回答 5

要安装或升级pip,官方网站下载get-pip.py。然后运行以下命令:

sudo python get-pip.py 

它将安装pip为您的运行脚本的python版本。

To install or upgrade pip, download get-pip.py from the official site. Then run the following command:

sudo python get-pip.py 

and it will install pip for your python version which runs the script.


回答 6

类似于Oksana,但添加了python3

$ brew rm python 
$ brew rm python3 
$ rm -rf /usr/local/opt/python
$ rm -rf /usr/local/opt/python3
$ brew prune 
$ brew install python3
$ brew postinstall python3

似乎现在适用于Mac OS X 10.13.3 Xcode 9.2的pip3

Similar to Oksana but add python3

$ brew rm python 
$ brew rm python3 
$ rm -rf /usr/local/opt/python
$ rm -rf /usr/local/opt/python3
$ brew prune 
$ brew install python3
$ brew postinstall python3

Seem now work for pip3 under mac os x 10.13.3 Xcode 9.2


回答 7

我在目录中运行以下<user>:<group><user>:<group>其他文件匹配的其他文件/usr/local/lib/python3.7/site-packages/

sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
brew postinstall python3

I ran the below where <user>:<group> matched the other <user>:<group> for other files in the /usr/local/lib/python3.7/site-packages/ directory:

sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
brew postinstall python3

回答 8

我也遇到了同样的问题,但brew install python3无法正常安装pip3

布雷会发出警告The post-install step did not complete successfully

它与自制有关,没有许可 /usr/local

创建目录(如果不存在)

sudo mkdir lib 
sudo mkdir Frameworks

在内部/usr/local授予自制权限,以便可以访问它们:

sudo chown -R $(whoami) $(brew --prefix)/*

现在ostinstall python3

brew postinstall python3

这将为您成功安装

I also encountered the same problem but brew install python3 does not work properly to install pip3.

brre will throw the warning The post-install step did not complete successfully.

It has to do with homebrew does not have permission to /usr/local

Create the directory if not exist

sudo mkdir lib 
sudo mkdir Frameworks

Give the permissions inside /usr/local to homebrew so it can access them:

sudo chown -R $(whoami) $(brew --prefix)/*

Now ostinstall python3

brew postinstall python3

This will give you a successful installation


回答 9

升级到Mac OS Catalina之后,并升级了所有vEnv模块,pip3停止工作(产生错误:“ TypeError:’模块’对象不可调用”)。

找到问题58386953,导致这里出现问题并解决。

  1. 从vEnv退出(我启动了新的Shell)
  2. sudo python3 -m pip uninstall pip (这是必要的,但没有解决问题,因为它删除了基本的Python点子,但没有碰到我的vEnv点子)
  3. sudo easy_install pip (在基本Python中而不是vEnv中重新安装pip)
  4. cd到您的计算机上,vEnv/bin然后键入“ source activate”进入vEnv
  5. rm pip pip3 pip3.6 (似乎是摆脱vEnv中虚假点的唯一方法)
  6. 现在pip已从vEnv中消失,我们可以在基本Python中使用一个(我无法在删除后将pip成功安装到vEnv中)

After upgrading to Mac OS Catalina, and upgrading all my vEnv modules, pip3 stopped working (gave error: “TypeError: ‘module’ object is not callable”).

Found question 58386953 which led to here and solution.

  1. Exit from vEnv (I started fresh shell)
  2. sudo python3 -m pip uninstall pip (this is necessary, but did not fix problem, because it removed the base Python pip, but didn’t touch my vEnv pip)
  3. sudo easy_install pip (reinstalling pip in base Python, not in vEnv)
  4. cd to your vEnv/bin and type “source activate” to get into vEnv
  5. rm pip pip3 pip3.6 (seems to be the only way to get rid of the bogus pip’s in vEnv)
  6. Now pip is gone from vEnv, and we can use the one in the base Python (I wasn’t able to successfully install pip into vEnv after deleting)

回答 10

如果您使用的是python3,请执行python3 get-pip.py。只是一个简单的命令。

if you’re using python3 just execute python3 get-pip.py . Just a simple command.


识别与pip一起安装的python软件包的依赖关系

问题:识别与pip一起安装的python软件包的依赖关系

当我冻结一个点子时,会看到大量未明确安装的Python软件包,例如

$ pip freeze
Cheetah==2.4.3
GnuPGInterface==0.3.2
Landscape-Client==11.01
M2Crypto==0.20.1
PAM==0.4.2
PIL==1.1.7
PyYAML==3.09
Twisted-Core==10.2.0
Twisted-Web==10.2.0
(etc.)

我有办法确定为什么pip安装了这些特定的依赖软件包吗?换句话说,如何确定将这些软件包作为依赖项的父软件包?

例如,我可能想使用Twisted,并且在我不了解不意外卸载或升级它之前,不要依赖于软件包。

When I do a pip freeze I see large number of Python packages that I didn’t explicitly install, e.g.

$ pip freeze
Cheetah==2.4.3
GnuPGInterface==0.3.2
Landscape-Client==11.01
M2Crypto==0.20.1
PAM==0.4.2
PIL==1.1.7
PyYAML==3.09
Twisted-Core==10.2.0
Twisted-Web==10.2.0
(etc.)

Is there a way for me to determine why pip installed these particular dependent packages? In other words, how do I determine the parent package that had these packages as dependencies?

For example, I might want to use Twisted and I don’t want to depend on a package until I know more about not accidentally uninstalling it or upgrading it.


回答 0

您可以尝试使用pipdeptree将依赖显示为树结构,例如:

$ pipdeptree
Lookupy==0.1
wsgiref==0.1.2
argparse==1.2.1
psycopg2==2.5.2
Flask-Script==0.6.6
  - Flask [installed: 0.10.1]
    - Werkzeug [required: >=0.7, installed: 0.9.4]
    - Jinja2 [required: >=2.4, installed: 2.7.2]
      - MarkupSafe [installed: 0.18]
    - itsdangerous [required: >=0.21, installed: 0.23]
alembic==0.6.2
  - SQLAlchemy [required: >=0.7.3, installed: 0.9.1]
  - Mako [installed: 0.9.1]
    - MarkupSafe [required: >=0.9.2, installed: 0.18]
ipython==2.0.0
slugify==0.0.1
redis==2.9.1

要运行它:

pip install pipdeptree


编辑:正如@Esteban在评论中指出的那样,您还可以反向列出树(带有-r或与单个包相对),-p <package_name>以查找可以运行的已安装Werkzeug:

$ pipdeptree -r -p Werkzeug
Werkzeug==0.11.15
  - Flask==0.12 [requires: Werkzeug>=0.7]

You could try pipdeptree which displays dependencies as a tree structure e.g.:

$ pipdeptree
Lookupy==0.1
wsgiref==0.1.2
argparse==1.2.1
psycopg2==2.5.2
Flask-Script==0.6.6
  - Flask [installed: 0.10.1]
    - Werkzeug [required: >=0.7, installed: 0.9.4]
    - Jinja2 [required: >=2.4, installed: 2.7.2]
      - MarkupSafe [installed: 0.18]
    - itsdangerous [required: >=0.21, installed: 0.23]
alembic==0.6.2
  - SQLAlchemy [required: >=0.7.3, installed: 0.9.1]
  - Mako [installed: 0.9.1]
    - MarkupSafe [required: >=0.9.2, installed: 0.18]
ipython==2.0.0
slugify==0.0.1
redis==2.9.1

To get it run:

pip install pipdeptree


EDIT: as noted by @Esteban in the comments you can also list the tree in reverse with -r or for a single package with -p <package_name> so to find what installed Werkzeug you could run:

$ pipdeptree -r -p Werkzeug
Werkzeug==0.11.15
  - Flask==0.12 [requires: Werkzeug>=0.7]

回答 1

pip show命令将显示指定软件包所需的软件包(请注意,必须已经安装了指定软件包):

$ pip show specloud

Package: specloud
Version: 0.4.4
Requires:
nose
figleaf
pinocchio

pip show 是在pip版本1.4rc5中引入的

The pip show command will show what packages are required for the specified package (note that the specified package must already be installed):

$ pip show specloud

Package: specloud
Version: 0.4.4
Requires:
nose
figleaf
pinocchio

pip show was introduced in pip version 1.4rc5


回答 2

正如我最近在hn线程上说的,我将推荐以下内容:

有一个requirements.txt带有主要依赖项的注释文件:

## this is needed for whatever reason
package1

安装依赖项:pip install -r requirements.txt。现在,您将获得具有依赖项的完整列表pip freeze -r requirements.txt

## this is needed for whatever reason
package1==1.2.3

## The following requirements were added by pip --freeze:
package1-dependency1==1.2.3
package1-dependency1==1.2.3

这使您可以在文件结构中保留注释,从而将依赖项与依赖项的依赖项很好地分开。这样一来,您需要删除其中之一的时间会更美好:)

请注意以下几点:

  • 您可以requirements.raw使用版本控制清理整个版本requirements.txt
  • 当心git url在此过程中被鸡蛋名称替换。
  • 依存关系的依依关系依字母顺序排列,因此您不直接知道哪个软件包需要哪个依存关系,但此时您实际上并不需要它。
  • 使用pip install --no-install <package_name>到表的具体要求。
  • 如果不使用,请使用virtualenv

As I recently said on a hn thread, I’ll recommend the following:

Have a commented requirements.txt file with your main dependencies:

## this is needed for whatever reason
package1

Install your dependencies: pip install -r requirements.txt. Now you get the full list of your dependencies with pip freeze -r requirements.txt:

## this is needed for whatever reason
package1==1.2.3

## The following requirements were added by pip --freeze:
package1-dependency1==1.2.3
package1-dependency1==1.2.3

This allows you to keep your file structure with comments, nicely separating your dependencies from the dependencies of your dependencies. This way you’ll have a much nicer time the day you need to remove one of them :)

Note the following:

  • You can have a clean requirements.raw with version control to rebuild your full requirements.txt.
  • Beware of git urls being replaced by egg names in the process.
  • The dependencies of your dependencies are still alphabetically sorted so you don’t directly know which one was required by which package but at this point you don’t really need it.
  • Use pip install --no-install <package_name> to list specific requirements.
  • Use virtualenv if you don’t.

回答 3

您也可以使用一条命令来将需求中的程序包通过管道传输到pip show。

cut -d'=' -f1 requirements.txt | xargs pip show

You may also use a one line command which pipes the packages in requirements to pip show.

cut -d'=' -f1 requirements.txt | xargs pip show

回答 4

首先pip freeze显示所有当前安装的Python软件包,不一定使用PIP。

其次,Python软件包确实包含有关依赖软件包以及所需版本的信息。您可以使用此处介绍的方法查看特定pkg的依赖性。升级软件包时,安装程​​序脚本(如PIP)将为您处理依赖项的升级。

为了解决软件包的更新问题,我建议使用PIP要求文件。您可以定义所需的软件包和版本,然后使用pip install一次安装它们。

First of all pip freeze displays all currently installed packages Python, not necessarily using PIP.

Secondly Python packages do contain the information about dependent packages as well as required versions. You can see the dependencies of particular pkg using the methods described here. When you’re upgrading a package the installer script like PIP will handle the upgrade of dependencies for you.

To solve updating of packages i recommend using PIP requirements files. You can define what packages and versions you need, and install them at once using pip install.


回答 5

使用pipupgrade

$ pip install pipupgrade
$ pipupgrade --format tree --all --check

pipupgrade显示依赖关系图并突出显示每个程序包以进行可能的更新(基于语义版本控制)。它还以漂亮的方式显示冲突的子依赖关系。pipupgrade还确保升级存在于多个Python环境中的软件包。与Python2.7 +,Python3.4 +和pip9 +,pip10 +,pip18 +,pip19 +兼容。

Use pipupgrade!

$ pip install pipupgrade
$ pipupgrade --format tree --all --check

pipupgrade displays a dependency graph and highlights each package for a possible update (based on semantic versioning). It also displays conflicting child dependencies in a pretty way. pipupgrade also ensures to upgrade packages present within multiple Python environments. Compatible with Python2.7+, Python3.4+ and pip9+, pip10+, pip18+, pip19+.


回答 6

(解决方法,不是真正的答案)

遇到同样的问题,因为没有安装lxml,我想知道谁需要lxml。 不是谁需要lxml。最终绕过了问题。

  1. 指出我的网站套件放置在哪里。

  2. 到那里,递归grep进行导入(最后一个grep的–invert-match用于从考虑中删除lxml自己的文件)。

是的,不是有关如何使用pip做到这一点的答案,但是无论出于何种原因,我在这里的建议都没有成功。

 site-packages me$ egrep -i --include=*.py  -r -n lxml . | grep import | grep --invert-match /lxml/

(workaround, not true answer)

Had the same problem, with lxml not installing and me wanting to know who needed lxml. Not who lxml needed. Ended up bypassing the issue by.

  1. noting where my site packages were being put.

  2. go there and recursive grep for the import (the last grep’s –invert-match serves to remove lxml’s own files from consideration).

Yes, not an answer as to how to use pip to do it, but I didn’t get any success out of the suggestions here, for whatever reason.

 site-packages me$ egrep -i --include=*.py  -r -n lxml . | grep import | grep --invert-match /lxml/

回答 7

我写了一个快速的脚本来解决这个问题。以下脚本将显示任何给定包的父(相关)包。这样,您可以确定升级或安装任何特定的软件包都是安全的。可以如下使用:dependants.py PACKAGENAME

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Find dependants of a Python package"""

import logging
import pip
import pkg_resources
import sys

__program__ = 'dependants.py'


def get_dependants(target_name):
    for package in pip._internal.utils.misc.get_installed_distributions():
        for requirement_package in package.requires():
            requirement_name = requirement_package.project_name
            if requirement_name == target_name:
                yield package.project_name


# configure logging
logging.basicConfig(format='%(levelname)s: %(message)s',
                    level=logging.INFO)

try:
    target_name = sys.argv[1]
except IndexError:
    logging.error('missing package name')
    sys.exit(1)

try:
    pkg_resources.get_distribution(target_name)
except pkg_resources.DistributionNotFound:
    logging.error("'%s' is not a valid package", target_name)
    sys.exit(1)

print(list(get_dependants(target_name)))

I wrote a quick script to solve this problem. The following script will display the parent (dependant) package(s) for any given package. This way you can be sure it is safe to upgrade or install any particular package. It can be used as follows: dependants.py PACKAGENAME

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Find dependants of a Python package"""

import logging
import pip
import pkg_resources
import sys

__program__ = 'dependants.py'


def get_dependants(target_name):
    for package in pip._internal.utils.misc.get_installed_distributions():
        for requirement_package in package.requires():
            requirement_name = requirement_package.project_name
            if requirement_name == target_name:
                yield package.project_name


# configure logging
logging.basicConfig(format='%(levelname)s: %(message)s',
                    level=logging.INFO)

try:
    target_name = sys.argv[1]
except IndexError:
    logging.error('missing package name')
    sys.exit(1)

try:
    pkg_resources.get_distribution(target_name)
except pkg_resources.DistributionNotFound:
    logging.error("'%s' is not a valid package", target_name)
    sys.exit(1)

print(list(get_dependants(target_name)))