在本文中,我们将带你了解Python-使用pip安装特定的软件包版本在这篇文章中,我们将为您详细介绍Python-使用pip安装特定的软件包版本的方方面面,并解答pip安装指定python版本常见的疑
在本文中,我们将带你了解Python-使用pip安装特定的软件包版本在这篇文章中,我们将为您详细介绍Python-使用pip安装特定的软件包版本的方方面面,并解答pip安装指定python版本常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的anaconda / conda-安装特定的软件包版本、php – 如何使用Composer安装特定版本的软件包?、Pip安装仅在软件包中安装顶级Python文件、python – 如何访问`pip –user`安装的软件包?。
本文目录一览:- Python-使用pip安装特定的软件包版本(pip安装指定python版本)
- anaconda / conda-安装特定的软件包版本
- php – 如何使用Composer安装特定版本的软件包?
- Pip安装仅在软件包中安装顶级Python文件
- python – 如何访问`pip –user`安装的软件包?
Python-使用pip安装特定的软件包版本(pip安装指定python版本)
我正在尝试使用通过该–no-site-packages
选项创建的新virtualenv安装MySQL_python适配器的1.2.2版本。PyPi中显示的当前版本是1.2.3。有没有安装旧版本的方法?我发现有一篇文章指出应该这样做:
pip install MySQL_python==1.2.2
但是,安装后,它仍显示MySQL_python-1.2.3-py2.6.egg-info
在站点包中。这是此软件包专用的问题,还是我做错了什么?
答案1
小编典典TL; DR:
pip install -Iv
(即pip install -Iv MySQL_python==1.2.2
)
首先,我发现你要执行的操作有两个问题。由于已经安装了版本,因此应该卸载当前的现有驱动程序或使用pip install -I MySQL_python==1.2.2
但是,你很快就会发现这不起作用。如果查看pip的安装日志,或者执行pip
的安装日志,pip install -Iv MySQL_python==1.2.2
则会发现PyPI URL链接不适用于MySQL_python v1.2.2
。你可以在这里验证:http : //pypi.python.org/pypi/MySQL-python/1.2.2
由于sourceforge.net
最近的升级和PyPI的过时URL,下载链接404s和后备URL链接正在无限重定向。
因此,要正确安装驱动程序,可以按照以下步骤操作:
pip uninstall MySQL_pythonpip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
答案2
小编典典你甚至可以在pip install
命令中使用版本范围。像这样:
pip install ''stevedore>=1.3.0,<1.4.0''
如果该软件包已经安装,并且你想降级,请添加–force-reinstall
以下代码:
pip install ''stevedore>=1.3.0,<1.4.0'' --force-reinstall
anaconda / conda-安装特定的软件包版本
我想使用conda在当前的活动环境中安装“ rope”软件包。当前,以下“绳索”版本可用:
(data_downloader)user@user-ThinkPad ~/code/data_downloader $ conda search ropeUsing Anaconda Cloud api site https://api.anaconda.orgFetching package metadata: ....cached-property 1.2.0 py27_0 defaults 1.2.0 py34_0 defaults 1.2.0 py35_0 defaults 1.3.0 py27_0 defaults 1.3.0 py34_0 defaults 1.3.0 py35_0 defaults rope 0.9.4 py26_0 defaults 0.9.4 py27_0 defaults 0.9.4 py33_0 defaults 0.9.4 py34_0 defaults 0.9.4 py26_1 defaults 0.9.4 py27_1 defaults 0.9.4 py33_1 defaults 0.9.4 py34_1 defaults . 0.9.4 py35_1 defaults
我想安装以下软件:
1.3.0 py35_0 defaults
我已经尝试过各种“ conda install”的排列方式,因为它们都不正确,所以这里不再列出。
我也不确定 py35_0 是什么(我假设这是针对其构建软件包的python版本?),我也不知道’defaults’是什么意思?
答案1
小编典典没有1.3.0
适用于的版本rope
。1.3.0
指包装cached-property
。的最高可用版本rope
是0.9.4
。
您可以使用安装不同的版本conda install package=version
。但是在这种情况下,只有一个版本,rope
因此您不需要。
你看到的原因cached-property
在此上市,是因为它包含字符串"rope"
:“缓存-P 绳 erty”
py35_0
表示您需要3.5
此特定版本的python版本。如果只有python3.4
该软件包且仅适用于版本3.5
,则无法使用conda进行安装。
我也不确定defaults
。这表明该软件包位于默认的conda通道内。
php – 如何使用Composer安装特定版本的软件包?
我正在尝试使用Composer安装特定版本的软件包.我尝试过composer install和composer require,但他们正在安装最新版本的软件包.如果我想要旧版本怎么办?
解决方法:
作曲家需要供应商/包:版本
例如:
作曲家需要refinery29 / test-util:0.10.2
Pip安装仅在软件包中安装顶级Python文件
我注意到在我的库的生成的.tar.gz中也没有丢失的文件。
我找到了答案,错误是我对 setup.py 的误解。
在其 packages 选项中,我仅提供了顶级源目录名称,并假定将对其进行递归解释。但这似乎并非如此。而是使用setuptools.find_packages()
来完成此工作。有关更多选项,请参见documentation。
python – 如何访问`pip –user`安装的软件包?
$python Python 2.7.10 (default,Oct 23 2015,18:05:06) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type "help","copyright","credits" or "license" for more information. >>> import numpy as np >>> np.version.full_version '1.8.0rc1'
我试图更新它,但由于某些原因我无法安装在整台机器上:
$sudo pip install -U numpy Password: Downloading/unpacking numpy from https://pypi.python.org/packages/dd/9f/cd0ec9c50e4ed8650901ad4afde164e5252b6182a9e0c7bff5f8b4441960/numpy-1.11.1.zip#md5=5caa3428b24aaa07e72c79d115140e46 Downloading numpy-1.11.1.zip (4.7MB): 4.7MB downloaded ... Found existing installation: numpy 1.8.0rc1 Uninstalling numpy: Cleaning up... Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/basecommand.py",line 134,in main status = self.run(options,args) File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/install.py",line 241,in run requirement_set.install(install_options,global_options,root=options.root_path) File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py",line 1294,in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py",line 525,in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py",line 1639,in remove renames(path,new_path) File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py",line 294,in renames shutil.move(old,new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py",line 302,in move copy2(src,real_dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py",line 131,in copy2 copystat(src,dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py",line 103,in copystat os.chflags(dst,st.st_flags) OSError: [Errno 1] Operation not permitted: '/tmp/pip-fajcj_-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info' Storing complete log in /Users/csaftoiu/Library/Logs/pip.log
好的,我只需安装到–user然后:
$pip install -U --user numpy ... Successfully installed numpy
但版本没有更新!
$python Python 2.7.10 (default,"credits" or "license" for more information. >>> import numpy as np >>> np.version.full_version '1.8.0rc1'
安装版本在哪里?
解决方法
Files will be installed into subdirectories of 07001 (written as userbase hereafter).
您可以看到这样的USER_BASE值:
$python -c "import site; print(site.USER_BASE)" /Users/csaftoiu/Library/Python/2.7
我发现在我的机器上,这是在sys.path上,但是它出现在全局安装目录之后.
我通过将它添加到我的〜/ .bash_profile来解决它:
# add user base to python path export PYTHONPATH=$(python -c "import site,os; print(os.path.join(site.USER_BASE,'lib','python','site-packages'))"):$PYTHONPATH
现在确实加载了最新版本:
$python Python 2.7.10 (default,"credits" or "license" for more information. >>> import numpy >>> numpy <module 'numpy' from '/Users/csaftoiu/Library/Python/2.7/lib/python/site-packages/numpy/__init__.pyc'> >>> numpy.version.full_version '1.11.1' >>>
今天关于Python-使用pip安装特定的软件包版本和pip安装指定python版本的介绍到此结束,谢谢您的阅读,有关anaconda / conda-安装特定的软件包版本、php – 如何使用Composer安装特定版本的软件包?、Pip安装仅在软件包中安装顶级Python文件、python – 如何访问`pip –user`安装的软件包?等更多相关知识的信息可以在本站进行查询。
本文标签: