Python3.4 versiyasini python3.6 ga oshirish ubuntu orqali pipsni kesadi

Hozirda python3.4-dan keyin python3.6 ni mashinamga o'rnatishga harakat qilaman. Ammo, python3.6 ostidagi pip ishlatish uchun o'rnatishni tugatgandan so'ng menga xato beradi:

Traceback (most recent call last):
  File "pip3", line 7, in 
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in 
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in 
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in 
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in 
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in 
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in 
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "pip3", line 7, in 
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in 
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in 
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in 
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

Internetdagi ushbu xatolik haqida bir necha bor sharhlar bor edi, ammo ularning hech birida aniq echim taklifi yo'q. Buni qanday hal qilishim mumkinligini hech kim bilmaydi?

24
Buni ishga tushiring: pip install -U pip setuptools
qo'shib qo'ydi muallif surfer190, manba
Bir yechim emas, lekin men bir python o'rnatilishini bitta mashinaga boshqarish uchun pyenvdan foydalanishni tavsiya qilaman.
qo'shib qo'ydi muallif Mephy, manba

6 javoblar

Buni manbalardan hech narsa o'rnatmasdan hal qila oldim. Mana nima qilganim:

  1. First, install pip for Python3.x (for some weird reason I didn't have it...)

    $ sudo apt-get install python3-pip
    

    It is an old version...

    $ pip3 --version
    pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
    
  2. ... so upgrade it to the latest

    $ sudo pip3 install --upgrade pip
    

    Now it is much better

    $ sudo pip3 --version
    pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
    

  1. Then upgrade virtualenvvwrapper

    $ sudo pip3 install --upgrade virtualenvwrapper
    # ...
    Successfully installed pbr-3.0.1 six-1.10.0 stevedore-1.22.0 virtualenv-15.1.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.2
    
  2. Now creating a new virtualenv works:

    $ mkvirtualenv -p `which python3.6` 
    

    pip also works:

    $ pip install django
    # ...
    Successfully installed django-1.11.2 pytz-2017.2
    
    $ pip freeze
    Django==1.11.2
    pytz==2017.2
    

Eslatma: Endi men sizning so'raganingizdan biroz ko'proq narsani anglayapsiz, ammo (siz qaerga qodirligini aniq bilmasdan) 2-qadamdan keyin sizda yaxshi bo'lishi kerak deb o'ylayman.

19
qo'shib qo'ydi
Men uchun yaxshi ishlaydi, rahmat. Natijada paydo bo'lgan virtual obyektlarni faollashtirishga urinish "ruxsat rad qilindi". Asl muammo bilan shug'ullanadigan narsa ekanligiga ishonchim komil emas, lekin men buni to'liqligi uchun eslayman.
qo'shib qo'ydi muallif glaucon, manba
upgrade pip3 muammomni echadi.
qo'shib qo'ydi muallif zixia, manba
menda ishlamayotgan bo'lsam, python2.7 o'rnatdim, python 3.4 o'rnatildi. @Igonato ning javoblari men uchun ishlaydi.
qo'shib qo'ydi muallif MeadowMuffins, manba

Xuddi shu muammo bor edi. Pythonni manbadan o'rnatish yordam berdi.

# Remove existing python 3.6 if installed with apt
$ sudo apt-get autoremove python3.6

# Get the source
$ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
$ tar xvf Python-3.6.1.tar.xz
$ cd Python-3.6.1

# Configure and install
$ sudo ./configure
$ sudo make altinstall

# Success!
$ pip3.6 -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Edit: I since discovered pyenv. Makes installing and managing different python versions a lot easier. Give it a try!

13
qo'shib qo'ydi
@drdaeman rahmat, bilish yaxshi! Lekin men javobni soddagina qoldirishni istayman. Siz nima deb o'ylaysiz? Bundan tashqari, apt versiyasi, umid qilamanki, yangilanadi va bu eskiradi.
qo'shib qo'ydi muallif Igonato, manba
Muammo, sudo make install (yoki altinstall yoki shunga o'xshash narsa) bilan hech kimning izini saqlamaydigan ba'zi fayllarni nusxalashni yakunlashingiz mumkin - ehtimol kelajakdagi yangilanishlarni murakkablashtirish yoki o'chirish. Men checkinstall kabi bir narsani ishlatishni o'ylab ko'ring.
qo'shib qo'ydi muallif drdaeman, manba
O'ylaymanki, mening sharhlarim etarli. Axir, bu aslida siz uchun ishlagan. Faqat biron-bir paketni boshqarishdan tashqari narsalarni o'rnatish keyingi vaqtlarda (masalan, apt/dpkg qo'shadi sifatida python3.6 ni o'rnatadigan bo'lsa)
qo'shib qo'ydi muallif drdaeman, manba

Faqat get-pip.py faylini yuklab oling bu yerda va bu buyruqdan foydalaning:

sudo python3 get-pip.py
2
qo'shib qo'ydi

Men Ubuntu 14.04 serverlarida 3,6 bilan Python 3.4 o'rniga o'tdingiz va men ham xuddi shu muammoga duch keldim. Menimcha, bu sabab qadimgi tizimga aylandi:

$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)

Men hech qachon python3-pipni o'rnatmadim. Buning o'rniga xatoni quyidagicha hal qildim:

$ sudo pip install --upgrade pip
$ sudo pip install --upgrade virtualenv
2
qo'shib qo'ydi

Men shu masala bilan shug'ullanardim. Mening tizimimda pkg_resources ning 2 versiyasi bor edi.

/usr/local/lib/python3.6/site-packages/pkg_resources.py

/usr/lib/python3.6/site-packages/pkg_resources/__ init __ py

Sistema yangi versiyani topishi uchun eski versiyani ko'chirib, men uchun tuzatdi.

mv /usr/local/lib/python3.6/site-packages/pkg_resources.py/usr/local/lib/python3.6/site-packages/pkg_resources.py.back

0
qo'shib qo'ydi

Uni qochib keta olmadim

python3 get-pip.py

yoki

pip3 install --upgrade

because there I already had issues with pkg_resources.py. Also re-installing the python3-setuptools package from Ubuntu did not help as this still seems to install the one fyokithe version originally installed with the Ubuntu system (3.4 in my case) but I could solve it by manually installing the setuptools via

wget https://bootstrap.pypa.io/ez_setup.py -O - | python3

Note: python3 points to my new python version 3.6. If thats not the case fyokiyou then you would need to run

wget https://bootstrap.pypa.io/ez_setup.py -O - | python3.6
0
qo'shib qo'ydi
Python
Python
372 ishtirokchilar

Bu guruh python dasturlash tilini muhokama qilish uchun. Iltimos, o'zingizni hurmat qiling va faqat dasturlash bo'yicha yozing. Botlar mavzusini @botlarhaqida guruhida muhokama qling! FAQ: @PyFAQ Offtopic: @python_uz_offtopic

Python offtopic group !
Python offtopic group !
150 ishtirokchilar

@python_uz gruppasining offtop gruppasi. offtop bo'lsa ham reklama mumkin emas ) Boshqa dasturlash tiliga oid gruppalar @languages_programming