Python 2.7, Requests Version 2.2.1 [duplicate] - python

This question already has answers here:
Unable to import Python's email module at all
(6 answers)
Closed 8 years ago.
Using Python 2.7, anyone know why I get this with requests 2.2.1 but not ver 1.2.3?And how to fix this?
Traceback (most recent call last):
File "krunchuploader.py", line 12, in <module>
from modules.core import confirm_customer_ddi, get_apikey
File "/home/one/trunk/stratus-krunch-uploader/stratus_krunch_uploader/modules/core.py", line 8, in <module>
import requests
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 39, in <module>
from .request import RequestMethods
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/packages/urllib3/request.py", line 12, in <module>
from .filepost import encode_multipart_formdata
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/packages/urllib3/filepost.py", line 15, in <module>
from .fields import RequestField
File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/requests/packages/urllib3/fields.py", line 7, in <module>
import email.utils
ImportError: No module named utils

I had a file email.py that I renamed, but the email.pyc was still causing the issue.

Related

ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found

I'm trying to install bern2 locally. bern2 installed successfully. when I started running, I got this error.
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/../../../libfaiss.so)
from normalizers.neural_normalizer import NeuralNormalizer
File "/home/ubuntu/BERN2/BERN2/normalizers/neural_normalizer.py", line 17, in <module>
import faiss
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/__init__.py", line 18, in <module>
from .loader import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/loader.py", line 65, in <module>
from .swigfaiss import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/swigfaiss.py", line 10, in <module>
from . import _swigfaiss
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/../../../libfaiss.so)
Traceback (most recent call last):
File "/home/ubuntu/BERN2/BERN2/server.py", line 1, in <module>
from app import create_app
File "/home/ubuntu/BERN2/BERN2/app/__init__.py", line 12, in <module>
import bern2
File "/home/ubuntu/BERN2/BERN2/bern2/__init__.py", line 1, in <module>
from bern2.bern2 import BERN2
File "/home/ubuntu/BERN2/BERN2/bern2/bern2.py", line 22, in <module>
from normalizer import Normalizer
File "/home/ubuntu/BERN2/BERN2/bern2/normalizer.py", line 11, in <module>
from normalizers.neural_normalizer import NeuralNormalizer
File "/home/ubuntu/BERN2/BERN2/normalizers/neural_normalizer.py", line 17, in <module>
import faiss
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/__init__.py", line 18, in <module>
from .loader import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/loader.py", line 65, in <module>
from .swigfaiss import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/swigfaiss.py", line 10, in <module>
from . import _swigfaiss
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/../../../libfaiss.so)
The reason could be that the system path is not configured correctly. Try this,
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
Source:
https://www.tensorflow.org/install/pip

Python problem with extensions in virtual enviroment [duplicate]

This question already has an answer here:
unknown version in python library pyparsing
(1 answer)
Closed 1 year ago.
I am using python 3.7.5 version, however I downloaded 3.6 version for specific project and created virtual enviroment, installed required extensions (numpy, matplotlib...). However when I try to run python script, there comes a lot of errors related to extensions. The code worked flawlessly with 3.7 version of python. Any thoughts what can be wrong?
File "c:/Users/zabul/OneDrive/Desktop/pyCode/Data_observation.py", line 4, in <module>
import pandas as pd
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-packages\pandas\__init__.py",
line 55, in <module>
from pandas.core.api import (
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-packages\pandas\core\api.py",
line 24, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\core\groupby\__init__.py", line 1, in <module>
from pandas.core.groupby.generic import ( # noqa: F401
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\core\groupby\generic.py", line 44, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-packages\pandas\core\frame.py",
line 115, in <module>
from pandas.core.series import Series
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\core\series.py", line 84, in <module>
import pandas.plotting
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\plotting\__init__.py", line 59, in <module>
from pandas.plotting._core import (
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\plotting\_core.py", line 17, in <module>
import pandas.plotting._matplotlib # noqa
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\plotting\_matplotlib\__init__.py", line 3, in <module>
from pandas.plotting._matplotlib.boxplot import (
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pandas\plotting\_matplotlib\boxplot.py", line 4, in <module>
from matplotlib.artist import setp
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\matplotlib\__init__.py", line 128, in <module>
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\matplotlib\rcsetup.py", line 29, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\matplotlib\fontconfig_pattern.py", line 26, in <module>
from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd,
File "C:\Users\zabul\OneDrive\Desktop\pyCode\.virtenv\lib\site-
packages\pyparsing\__init__.py", line 130, in <module>
__version__ = __version_info__.__version__
AttributeError: 'version_info' object has no attribute '__version__'
This subject unknown version in python library pyparsing is the same as this one. Your error seems to be on pyparsing.

How to solve the problem "AttributeError: module 'linecache' has no attribute 'checkcache'" [duplicate]

This question already has answers here:
'module' object has no attribute 'loads' while parsing JSON using python [duplicate]
(2 answers)
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 3 years ago.
I am trying to import Numpy
import numpy as np
but I am getting this error:
AttributeError: module 'linecache' has no attribute 'checkcache'
Full trace:
Traceback (most recent call last):
File "C:/Users/z1885/Desktop/鸡行为分析/codepy/ML/KNN.py", line 1, in <module>
import numpy as np
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\__init__.py", line 145, in <module>
from . import lib
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\lib\__init__.py", line 24, in <module>
from .npyio import *
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\lib\npyio.py", line 14, in <module>
from ._datasource import DataSource
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\lib\_datasource.py", line 41, in <module>
import shutil
File "C:\Users\z1885\Desktop\bouk\venv\lib\shutil.py", line 16, in <module>
import bz2
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\bz2.py", line 18, in <module>
from threading import RLock
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\z1885\Desktop\bouk\venv\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Users\z1885\Desktop\bouk\venv\lib\tokenize.py", line 34, in <module>
from token import *
File "C:\Users\z1885\Desktop\鸡行为分析\codepy\token.py", line 5, in <module>
import request as request
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\request\__init__.py", line 2, in <module>
from get import GET
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\get\__init__.py", line 3, in <module>
from query_string import query_string
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\query_string\__init__.py", line 18, in <module>
#public.add
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\public\__init__.py", line 65, in add
return _add(_caller_modules()[1], objects)
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\public\__init__.py", line 12, in _caller_modules
frames = inspect.getouterframes(inspect.currentframe())
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\inspect.py", line 1441, in getouterframes
frameinfo = (frame,) + getframeinfo(frame, context)
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\inspect.py", line 1414, in getframeinfo
lines, lnum = findsource(frame)
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\inspect.py", line 747, in findsource
linecache.checkcache(file)
AttributeError: module 'linecache' has no attribute 'checkcache'

got error on using pygccxml lib in python program for variable parsing

Traceback (most recent call last):
File "parseVar.py", line 1, in <module>
from pygccxml import utils
File "/usr/local/lib/python2.7/dist-packages/pygccxml/__init__.py", line 29, in <module>
from . import declarations
File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/__init__.py", line 16, in <module>
from .declaration import declaration_t
File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/declaration.py", line 13, in <module>
from . import algorithms_cache
File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/algorithms_cache.py", line 11, in <module>
from .. import utils
File "/usr/local/lib/python2.7/dist-packages/pygccxml/utils/__init__.py", line 11, in <module>
from .utils import is_str
File "/usr/local/lib/python2.7/dist-packages/pygccxml/utils/utils.py", line 12, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "/home/jayesh/Desktop/random.py", line 10, in <module>
print random.uniform(1.2, 2.5)
AttributeError: 'module' object has no attribute 'uniform'
Can somebody please suggest how to fix this issue?

Cannot `import smtplib`

When ever I try to import smtplib in the Python interpreter, I get this error:
ImportError: cannot import name fix_eols
How can I fix this?
Edit:
Here is the full stack trace:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 46, in <module>
import email.utils
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 32, in <module>
from email._parseaddr import quote
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/_parseaddr.py", line 16, in <module>
import time, calendar
File "/Users/aaronblock/Documents/programming/scripts/calendar.py", line 7, in <module>
File "/usr/local/lib/python2.7/site-packages/apiclient/__init__.py", line 19, in <module>
from googleapiclient import discovery
File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 38, in <module>
from email.generator import Generator
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/generator.py", line 15, in <module>
from email.header import Header
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/header.py", line 16, in <module>
import email.quoprimime
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/quoprimime.py", line 49, in <module>
from email.utils import fix_eols
ImportError: cannot import name fix_eols
Just to point out how to detect this kinds of errors (since it does happen from time to time):
Pay attention to the stacktrace. In this example, the problem can be seen in the line:
File "/Users/aaronblock/Documents/programming/scripts/calendar.py", line 7, in <module>
which certainly indicates wrong file being imported when we're trying to import a system-wide library.
I had a file called "calendar.py" which messes up my Python environment because smtplib needs calendar.py in order to work. Deleting calendar.py solved my problem.

Categories