Python版本冲突和pip3

时间:2016-09-11 10:36:19

标签: python python-3.x pip

这是我正在处理的艰难局面。这是我的问题的简短版本:

  • 我正在使用Ubuntu 12.04
  • 我想在Python 3.5.x库中安装openCV。我还想使用pip3来管理python的包安装。

以下是我的蟒蛇版本的样子

    $ python --version
      Python 2.7.3
    $ python3 --version
      Python 3.5.2

到目前为止,我已经实现了目标。

当我使用virtualenv来管理python3个库时:

   virtualenv -p /usr/bin/python3 py3env
   source py3env/bin/activate

我看到我的python版本如下:

   (py3env)yxxxxa@yxxxxa-Precision-M4800:~$ python3 --version
    Python 3.2.3

我似乎在我的机器3.2.3中有另一个版本的python搞乱了我安装的版本3.5.2。这是我的第一个问题。

第二个相关问题是我无法安装pip 3。由于相同的python版本冲突,我收到此错误:

 $ pip
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor /pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
  warnings.warn(msg)
 Traceback (most recent call last):
   File "/usr/local/bin/pip", line 9, in <module>
 load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
   File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in  load_entry_point
 return get_distribution(dist).load_entry_point(group, name)
   File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
 return ep.load()
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
  entry = __import__(self.module_name, globals(),globals(), ['__name__'])
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
   from pip.vcs import git, mercurial, subversion, bazaar  # noqa
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
   from pip.download import path_to_url
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
   from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
   from pip._vendor.progress.bar import Bar, IncrementalBar
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
                  ^
   SyntaxError: invalid syntax
   yasharatena@yasharatena-Precision-M4800:~$ pip3
  /usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
   warnings.warn(msg)
   Traceback (most recent call last):
    File "/usr/local/bin/pip3", line 9, in <module>
   load_entry_point('pip==8.1.2', 'console_scripts', 'pip3')()
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
   return get_distribution(dist).load_entry_point(group, name)
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in  load_entry_point
   return ep.load()
   File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
   entry = __import__(self.module_name, globals(),globals(), ['__name__'])
   File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
    from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
    from pip._vendor.progress.bar import Bar, IncrementalBar
    File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
    empty_fill = u'∙'
                  ^
    SyntaxError: invalid syntax

您对所述问题有什么专家意见?有什么好主意来处理这个吗?非常感谢

1 个答案:

答案 0 :(得分:1)

  

这解决了我的第一个问题。现在第二个问题仍然存在,如何   我可以在python 3.5.2下安装pip3(最好使用viretualenv)吗?

以下是答案:

python3 -m virtualenv py3env

source py3env/bin/activate

Python 3.5默认情况下应该有pip,也可以在上面的命令之后使用pip :)

例如:

python -m pip install requests

编辑:

Here如果在创建virtualenv后仍需要安装pip,你可以找到非常好的解释。