I tried to install Django Framework in Ubuntu. and i am using python 3.8. but in normal instalation, Django 1.1 had been installed. and i changed the python3 alternative to python3.8 . and usuing python3 -m pip install django. and i installed Django(v 3.3) and used it. but after the changing the alternative, the Terminal doesn't open and start.
i deleted python3.6 from my ubuntu. and the problems had been started after that.
it seems some programs in linux run in python3.6 and after deleting that,
i can't fix the problems and the Terminal windows does not open. i tried other ways (changing the gnome-terminal file, changing the alternative to default v3.6 and fix the Broken distro), but they didn't help me. i can't open Terminal, and when i ran sudo apt update i recieved this Errors:
Any idea?
File has unexpected size (1133 != 1128). Mirror sync in progress? [IP: ***.**.***.** 80]
Release file created at: Wed, 06 May 2020 19:27:45 +0000 Fetched 1,762 B in 2s (932 B/s) Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 7, in <module>
import sqlite3 File "/usr/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import * File "/usr/lib/python3.6/sqlite3/dbapi2.py", line 23, in <module>
import datetime File "/usr/lib/python3.6/datetime.py", line 8, in <module>
import math as _math ModuleNotFoundError: No module named 'math' 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 <module>
from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, re, pwd, grp, os, time, io File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess ModuleNotFoundError: No module named '_posixsubprocess'
Original exception was: Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 7, in <module>
import sqlite3 File "/usr/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import * File "/usr/lib/python3.6/sqlite3/dbapi2.py", line 23, in <module>
import datetime File "/usr/lib/python3.6/datetime.py", line 8, in <module>
import math as _math ModuleNotFoundError: No module named 'math' Reading package lists... Done E: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages.gz File has unexpected size (1133 != 1128). Mirror sync in progress? [IP:
* 80] Hashes of expected file:
- Filesize:1128 [weak]
- SHA256:*
- SHA1:*
- MD5Sum:*
Release file created at: Wed, 06 May 2020 19:27:45 +0000 E: Some index files failed to download. They have been ignored, or old ones used instead. E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi' E: Sub-process returned an error code
and below result showed when i tried to run django-admin:
Traceback (most recent call last):
File "/usr/bin/django-admin", line 5, in <module>
from django.core.management import execute_from_command_line
File "/home/pytm/.local/lib/python3.6/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/pytm/.local/lib/python3.6/site-packages/django/utils/version.py", line 1, in <module>
import datetime
File "/usr/lib/python3.6/datetime.py", line 8, in <module>
import math as _math
ModuleNotFoundError: No module named 'math'
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 <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, re, pwd, grp, os, time, io
File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/django-admin", line 5, in <module>
from django.core.management import execute_from_command_line
File "/home/pytm/.local/lib/python3.6/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/pytm/.local/lib/python3.6/site-packages/django/utils/version.py", line 1, in <module>
import datetime
File "/usr/lib/python3.6/datetime.py", line 8, in <module>
import math as _math
ModuleNotFoundError: No module named 'math'
profiling:/home/user/Downloads/Python-3.6.10/Programs/python.gcda:Cannot open
profiling:/home/user/Downloads/Python-3.6.10/Modules/xxsubtype.gcda:Cannot open
after a few hours, i found a way to fix the problems.
First, I made a backup of all my data(I would recommend to everyone trying this). Although it worked for me, it may fail for some reason on your machine and you don't want to lose your data.
I ran the following commands to remove the old version of python3.6 without removing all the dependencies and to directly install the default version.
sudo dpkg --remove --force-depends python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib
sudo apt-get install python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib
I ran sudo apt-get update and sudo apt-get upgrade before rebooting my machine.
everything became ok..
Related
I installed pycurl for python3
but when I want to import it to Pycharm and use it I get this error message:
Traceback (most recent call last):
File "/home/cours/PycharmProjects/untitled2/venv/test.py", line 1, in <module>
import pycurl
ModuleNotFoundError: No module named 'pycurl'
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 <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "/home/cours/PycharmProjects/untitled2/venv/test.py", line 1, in <module>
import pycurl
ModuleNotFoundError: No module named 'pycurl'
But when I install it with the Pycharm terminal (pip install pycurl) I get this message
Requirement already satisfied: pycurl in /usr/lib/python3/dist-packages (7.43.0.1)
I also already imported the package with : Settings -> Python Interpreter
And finally i also used : "Inherit global site-package" option of the project and the problem is the same
I have no idea what else i can do
use command this command to install package -
pip3 install pycurl
and also check the Pycharm python version in for code compile
I am using requests module in my python program. It worked great in the previous day. But now, when importing requests module, it is showing a weird error. It is working great in python2 version. But shows error in python3. I googled it but can't find a solution. I haven't changed anything. Why it is showing this error.
Here it is:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/paulsteven/.local/lib/python3.5/site-packages/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/paulsteven/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/_util.py", line 3, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 188, in <module>
_verify_package_version(cryptography.__version__)
File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 175, in _verify_package_version
so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)
AttributeError: cffi library '_openssl' has no function, constant or global variable named 'CRYPTOGRAPHY_PACKAGE_VERSION'
Reinstalling cryptography package will resolve this problem.
When I used command : pip freeze it shows message error follow:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 6, in <module>
import io
File "/usr/local/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: /usr/local/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyCodec_LookupTextEncoding
which pip:
/usr/local/bin/pip
which python:
/usr/local/bin/python
I do not know why it's in error ! so I hope anybody can help me to resolve problem ! thank you.
I have python2.7 and python3.5 installed via Macports. I am trying to get neovim up and running and for this I ran
$ sudo pip2 install neovim
$ sudo pip-3.5 install neovim
Which installs the packages into different subdirs of /opt/local/Library/Frameworks/Python.framework/Versions/. Now when running Python 3.5, import neovim tries to load the 2.7 package (which fails), as I can see from the stack trace.
The full error is this:
$ python3.5 -c "import neovim"
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/msgpack_rpc/event_loop/__init__.py", line 7, in <module>
from .uv import UvEventLoop
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/msgpack_rpc/event_loop/uv.py", line 5, in <module>
import pyuv
ImportError: No module named 'pyuv'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/msgpack_rpc/event_loop/asyncio.py", line 19, in <module>
import asyncio
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py", line 18, in <module>
import concurrent.futures
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/concurrent/futures/_base.py", line 357
raise type(self._exception), self._exception, self._traceback
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/__init__.py", line 11, in <module>
from .msgpack_rpc import (ErrorResponse, child_session, socket_session,
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/msgpack_rpc/__init__.py", line 8, in <module>
from .event_loop import EventLoop
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/msgpack_rpc/event_loop/__init__.py", line 12, in <module>
from .asyncio import AsyncioEventLoop
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/msgpack_rpc/event_loop/asyncio.py", line 22, in <module>
import trollius as asyncio
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trollius/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trollius/base_events.py", line 39, in <module>
from . import coroutines
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trollius/coroutines.py", line 16, in <module>
from . import futures
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trollius/futures.py", line 19, in <module>
from . import executor
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trollius/executor.py", line 12, in <module>
import concurrent.futures
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/concurrent/futures/_base.py", line 357
raise type(self._exception), self._exception, self._traceback
^
SyntaxError: invalid syntax
What do I have to do in order for Python 2.7 and 3 to coexist peacefully on my system?
I recently had this problem as well, but it was not related to PYTHONPATH, which on my machine was unset. In my situation Python and pip were installed via MacPorts. Cleaning, self-updating MacPorts and then updating pip to the most recent version, and then running the following resolved the issue:
port select --set pip pip35
I have a ubuntu server.(10.04)
I don't install requests module. I try pip and other methods. Usually ;
$ sudo pip install requests
Traceback (most recent call last):
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
from ssl import CertificateError, match_hostname
ImportError: cannot import name CertificateError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 7, in <module>
from backports.ssl_match_hostname import CertificateError, match_hostname
ImportError: No module named backports.ssl_match_hostname
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.5', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.1/dist-packages/distribute-0.6.49-py3.1.egg/pkg_resources.py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.1/dist-packages/distribute-0.6.49-py3.1.egg/pkg_resources.py", line 2382, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.1/dist-packages/distribute-0.6.49-py3.1.egg/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/download.py", line 22, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 31, in <module>
from .packages.ssl_match_hostname import CertificateError
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
from . import ssl_match_hostname
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 10, in <module>
from _implementation import CertificateError, match_hostname
ImportError: No module named _implementation
I guess I have already setup pip 3.1. But following
$ pip -V
Then I see same problem. How to install requests module for Python 3.1 ubuntu server 10.04?
Have you tried easy_install requests?
Or you could try a non-fancy way. Google requests package, download it, unzip it and then run setup.py script like this:
python setup.py install
Have you tried pip install backports.ssl-match-hostname
Probably no harm to upgrade Python either.