Import python packages with different versions installed

核能气质少年 提交于 2020-03-22 10:33:34

问题


I have a problem. I'm trying to install a script written in python. It requires 3.4+ version, and I have python2.7 python3.4 python3.5 installed on my ubuntu 15.10 by default. During setup it throws an error which I found is concerning missing packages in python.

The error is

File "/usr/lib/python3.4/distutils/dist.py", line 1209, in set_requires distutils.versionpredicate.VersionPredicate(v)
File "/usr/lib/python3.4/distutils/versionpredicate.py", line 114, in __init__ raise ValueError("expected parenthesized list: %r" % paren) 
ValueError: expected parenthesized list: '-branch'

I looked into source, found list of required packages and made a small script which gives me missing ones

import pip
installed_packages = pip.get_installed_distributions()
flat_installed_packages = [package.project_name for package in installed_packages]
packages = [
    "aiohttp",
    "httplib2",
    "socksipy-branch",
    "requests",
    "dns",
    "url"
]
for needle in packages:
    if needle in flat_installed_packages:
        print('Found ', needle)
    else:
        print('Not found ', needle)`

Output is

Found  aiohttp
Found  httplib2
Not found  socksipy-branch
Found  requests
Not found  dns
Found  url

I tried to install these with synaptic manager, with manual apt-get, with pip, pip3, pip3.4 but with no luck. As I can see from random messages during package installation it installs them into python 2.7, no matter what I do. How do I get them into 3.4 version? Please help me.

来源:https://stackoverflow.com/questions/35600492/import-python-packages-with-different-versions-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!