Python problem with extensions in virtual enviroment [duplicate] - python

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.

Related

AttributeError: module 'dill' has no attribute '_dill' when importing datasets

In Python 3.9.13, when importing the package datasets, I get an AttributeError from the dill package.
I am running the following versions :
datasets : 2.9.0
dill : 0.3.6
Is there any specific modification of the packages needed ?
Thank you for your help
From :
import datasets
i get :
import datasets
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\__init__.py", line 43, in <module>
from .arrow_dataset import Dataset
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\arrow_dataset.py", line 66, in <module>
from .arrow_writer import ArrowWriter, OptimizedTypedSequence
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\arrow_writer.py", line 27, in <module>
from .features import Features, Image, Value
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\features\__init__.py", line 17, in <module>
from .audio import Audio
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\features\audio.py", line 12, in <module>
from ..download.streaming_download_manager import xopen
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\download\__init__.py", line 9, in <module>
from .download_manager import DownloadManager, DownloadMode
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\download\download_manager.py", line 36, in <module>
from ..utils.py_utils import NestedDataStructure, map_nested, size_str
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\utils\py_utils.py", line 602, in <module>
class Pickler(dill.Pickler):
File "C:\ProgramData\Anaconda3\lib\site-packages\datasets\utils\py_utils.py", line 605, in Pickler
dispatch = dill._dill.MetaCatchingDict(dill.Pickler.dispatch.copy())
AttributeError: module 'dill' has no attribute '_dill'```

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

importing pandas module, Attribute error with "pickle" module

My code: import pandas
Error showing:
File "D:/.../pandas_test.py", line 1, in <module>
import pandas
File "C:\...\anaconda3\lib\site-packages\pandas\__init__.py", line 55, in <module>
from pandas.core.api import (
File "C:\...\anaconda3\lib\site-packages\pandas\core\api.py", line 29, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "C:\...\anaconda3\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
File "C:\...\anaconda3\lib\site-packages\pandas\core\groupby\generic.py", line 60, in <module>
from pandas.core.frame import DataFrame
File "C:\...\anaconda3\lib\site-packages\pandas\core\frame.py", line 104, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "C:\...\anaconda3\lib\site-packages\pandas\core\generic.py", line 151, in <module>
class NDFrame(PandasObject, SelectionMixin, indexing.IndexingMixin):
File "C:\...\anaconda3\lib\site-packages\pandas\core\generic.py", line 2670, in NDFrame
protocol: int = pickle.HIGHEST_PROTOCOL,
AttributeError: module 'pickle' has no attribute 'HIGHEST_PROTOCOL'
Process finished with exit code 1
I worked with pandas module last week with the same PC there was no problem. I faced this error today. Don't know much about pickle module.
I've reinstalled pandas module nothing changed.
Python version: 3.7.6
Windows 10

NLTK Python error at running

I have installed the nltk in anaconda and tried some examples in this tutorial set pythonprogramming.net
After running the Classifier saving example it is showing some errors at the anaconda console as follows:
(C:\Users\Public\Anaconda) C:\Users\Kalanka PC>pickle.py
Traceback (most recent call last):
File "C:\Users\Kalanka PC\pickle.py", line 1, in <module>
import nltk
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\__init__.py", line 114, in <module>
from nltk.collocations import *
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\metrics\__init__.py", line 24, in <module>
from nltk.metrics.segmentation import windowdiff, ghd, pk
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\metrics\segmentation.py", line 45, in <module>
import numpy as np
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\core\__init__.py", line 36, in <module>
from . import numeric
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\core\numeric.py", line 37, in <module>
import pickle
File "C:\Users\Kalanka PC\pickle.py", line 4, in <module>
from nltk.corpus import movie_reviews
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\corpus\__init__.py", line 66, in <module>
from nltk.corpus.reader import *
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\corpus\reader\__init__.py", line 59, in <module>
from nltk.corpus.reader.tagged import *
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\corpus\reader\tagged.py", line 18, in <module>
from nltk.tag import str2tuple, map_tag
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\tag\__init__.py", line 63, in <module>
from nltk.tag.sequential import (SequentialBackoffTagger, ContextTagger,
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\tag\sequential.py", line 26, in <module>
from nltk.classify import NaiveBayesClassifier
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\classify\__init__.py", line 93, in <module>
from nltk.classify.scikitlearn import SklearnClassifier
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\classify\scikitlearn.py", line 42, in <module>
from sklearn.feature_extraction import DictVectorizer
File "C:\Users\Public\Anaconda\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "C:\Users\Public\Anaconda\lib\site-packages\sklearn\base.py", line 10, in <module>
from scipy import sparse
File "C:\Users\Public\Anaconda\lib\site-packages\scipy\__init__.py", line 70, in <module>
from numpy.random import rand, randn
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\random\__init__.py", line 99, in <module>
from .mtrand import *
File "numpy.pxd", line 86, in init mtrand (numpy\random\mtrand\mtrand.c:42488)
AttributeError: module 'numpy' has no attribute 'dtype'
when I try to install it again it shows as follows:
C:\Users\Kalanka PC>pip install nltk
Requirement already satisfied: nltk
in c:\users\public\anaconda\lib\site-packages Requirement already satisfied: six in c:\users\public\anaconda\lib\site-packages (from nltk)
Here the naming of the python file is same as the pickle.so it will confuse in loading the related files.
Ex:
the file name is pickle.py
and the code is as follows:
`import nltk`
`import random`
`import pickle`
You may be have saved the file with the name of pickle.py, as it tries to import your pickle file rather than the standard pickle in the module.
I had a similar problem while using pickle, I saved the code file with the name pickle. then when I execute it look for the file you created not the Standard module pickle

Python 2.7, Requests Version 2.2.1 [duplicate]

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.

Categories