Random errors in Anaconda3 - python

C:\Users\jesper>pip Traceback (most recent call last): File
"D:\Anaconda3\Scripts\pip-script.py", line 3, in <module>
import pip File "D:\Anaconda3\lib\site-packages\pip\__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog File "D:\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 22, in
<module>
from pip.compat import console_to_str, expanduser, stdlib_pkgs File "D:\Anaconda3\lib\site-packages\pip\compat\__init__.py", line 11,
in <module>
from logging.config import dictConfig as logging_dictConfig File "D:\Anaconda3\lib\logging\config.py", line 30, in <module>
import logging.handlers File "D:\Anaconda3\lib\logging\handlers.py", line 26, in <module>
import logging, socket, os, pickle, struct, time, re File "D:\Anaconda3\lib\socket.py", line 123, in <module>
class socket(_socket.socket): TypeError: __weakref__ slot disallowed: either we already got one, or __itemsize__ != 0
I get this now, and it happened randomly and keeps recurring. I can't use Python at the moment. I tried re-installing the entire conda library and tried different locations for Anaconda. Even tried installing Anaconda for 2.7 and it still didn't work. If someone knows how to fix I'd be in there eternal debt. Thanks!

Related

cvxpy import error : cannot read file data

I'm trying to use cvxpy on a pythonanywhere server, the installation was ok, no errors however when i want to import cvpxy as cp, i have an error, help me please
the error :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/cvxpy/__init__.py", line 18, in <module>
from cvxpy.atoms import *
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/cvxpy/atoms/__init__.py", line 17, in <module>
from cvxpy.atoms.cummax import cummax
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/cvxpy/atoms/cummax.py", line 17, in <module>
from cvxpy.atoms.atom import Atom
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/cvxpy/atoms/atom.py", line 21, in <module>
from cvxpy.expressions.constants import Constant
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/cvxpy/expressions/constants/__init__.py", line 17, in <module>
from .constant import Constant
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/cvxpy/expressions/constants/constant.py", line 22, in <module>
from scipy.sparse.linalg import eigsh
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/scipy/sparse/linalg/__init__.py", line 111, in <module>
from .isolve import *
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/scipy/sparse/linalg/isolve/__init__.py", line 4, in <module>
from .iterative import *
File "/home/padacore/.virtualenvs/env/lib/python3.7/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 8, in <module>
from . import _iterative
ImportError: /home/padacore/.virtualenvs/env/lib/python3.7/site-packages/scipy/sparse/linalg/isolve/../../../../scipy.libs/libopenblasp-r0-085ca80a.3.9.so: cannot read file data
It could be something to do with Atom, try switching to another editor. I recommend PyCharm or VSCode. If you're choosing VSCode, install these extensions: Python, PyLance, and Jupyter.
If you don't like VSCode's default themes, and miss Atom's One Dark, then there's an extension just for that! Just search for it, and you'll find it!
EDIT: If it wasn't something to do with Atom, maybe install an older version of cvxpy

Xcode update broke gcloud and gsutil

A few hours ago I updated Xcode to the latest version, which caused gcloud and gsutil commands to stop working. For example, a minute before the update finished, the command gsutil -m rsync was working fine.
While writing this question, I noticed I no longer have git working.
Since I'm not a Python guy, can someone please explain to me what the hell happened now? I would love some help.
python -V output is Python 2.7.16.
python3 -V output is Python 3.9.0.
pip -V output is pip 20.2.3 from /Users/<MY_USER>/Library/Python/2.7/lib/python/site-packages/pip (python 2.7)
pip3 -V output is pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)
This is what I get for gcloud help:
Traceback (most recent call last):
File "/Users/<MY_USER>/gcloud/sdk/lib/gcloud.py", line 104, in <module>
main()
File "/Users/<MY_USER>/gcloud/sdk/lib/gcloud.py", line 62, in main
from googlecloudsdk.core.util import encoding
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
import enum
File "/Users/<MY_USER>/gcloud/sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
And this is what I get for gsutil help:
Traceback (most recent call last):
File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/gsutil.py", line 13, in <module>
import bootstrapping
File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
import setup # pylint:disable=g-import-not-at-top
File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/setup.py", line 57, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
import enum
File "/Users/<MY_USER>/gcloud/sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
So after almost a day with nothing, I found a solution: what I needed to do was set an environment variable named CLOUDSDK_PYTHON to /usr/bin/python.
I edited my .zprofile and added:
export CLOUDSDK_PYTHON="/usr/bin/python"
I still have no idea what caused it, so I'll be glad for an explanation if anyone cares to take the time.

functools has no attribute lru_cache

I'm using Python 3.7 on my Windows
This error occurs while running every code:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import nltk
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\nltk\__init__.py", line 99, in <module>
from nltk.internals import config_java
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\nltk\internals.py", line 11, in <module>
import subprocess
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 50, in <module>
import signal
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\signal.py", line 3, in <module>
from functools import wraps as _wraps
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\functools.py", line 21, in <module>
from collections import namedtuple
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\collections\__init__.py", line 22, in <module>
from keyword import iskeyword as _iskeyword
File "C:\Users\HP\Desktop\tweepy\keyword.py", line 1, in <module>
import re
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\re.py", line 297, in <module>
#functools.lru_cache(_MAXCACHE)
AttributeError: module 'functools' has no attribute 'lru_cache'
How to fix it?
It looks like someone published a functools package on pypi, so if you had run:
# don't run this!
pip install functools
You may have accidentally installed that package. If you encounter this error, I would:
pip uninstall functools
To make sure that the functools you are using are the base package functools.
(I ended up here because I attempted to use functools.cache, which seems to only be present in Python 3.8, not earlier.)
I had the same error recently and it was because I had a file called functools.py in my project. Renaming it fixed the issue.

jupyter lab is broken how can I fix it?

I can't figure out why jupyter-lab is not working. something is broken and don't know where. I have searched the web for this and can't find a solution. COuld you please help. Appreciate it.
E:\gitrepos>jupyter lab
`Traceback (most recent call last):
File "E:\anaconda3\Scripts\jupyter-lab-script.py", line 3, in <module>
import jupyterlab.labapp
File "E:\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 7, in <module>
from notebook.notebookapp import NotebookApp, aliases, flags
File "C:\Users\Dario.Romero\AppData\Roaming\Python\Python35\site-packages\notebook\notebookapp.py", line 78, in <module>
from .services.kernels.kernelmanager import MappingKernelManager
File "C:\Users\Dario.Romero\AppData\Roaming\Python\Python35\site-packages\notebook\services\kernels\kernelmanager.py", line 19, in <module>
from jupyter_client.session import Session
File "E:\anaconda3\lib\site-packages\jupyter_client\session.py", line 61, in <module>
from jupyter_client.jsonutil import extract_dates, squash_dates, date_default
File "E:\anaconda3\lib\site-packages\jupyter_client\jsonutil.py", line 11, in <module>
from dateutil.parser import parse as _dateutil_parse
ImportError: No module named 'dateutil.parser'`
You need to install the dateutil library: https://pypi.python.org/pypi/python-dateutil/
(If you used a package manager, the dependencies for JupyterLab should already have been installed. If you didn't, then you will need to install the dependencies yourself.)

Why can't I import nltk?

In windows with a 64 bit OS, once I installed nltk-2.0.4.win-amd64-py2.7.exe,from http://www.lfd.uci.edu/~gohlke/pythonlibs/, for my 64 bit python, I ran 'import nltk' to get the following error!
Traceback (most recent call last):
File "<pyshell#25>", line 1, in <module>
import nltk
File "C:\Python27\lib\site-packages\nltk\__init__.py", line 131, in <module>
from inference import *
File "C:\Python27\lib\site-packages\nltk\inference\__init__.py", line 19, in <module>
from discourse import (ReadingCommand, CfgReadingCommand,
File "C:\Python27\lib\site-packages\nltk\inference\discourse.py", line 54, in <module>
from nltk.sem.glue import DrtGlue
File "C:\Python27\lib\site-packages\nltk\sem\glue.py", line 13, in <module>
from nltk.corpus import brown
File "C:\Python27\lib\site-packages\nltk\corpus\__init__.py", line 70, in <module>
from reader import *
File "C:\Python27\lib\site-packages\nltk\corpus\reader\__init__.py", line 85, in <module>
from nltk.corpus.reader.pl196x import *
File "C:\Python27\lib\site-packages\nltk\corpus\reader\pl196x.py", line 11, in <module>
from nltk import tokenize, tree
ImportError: cannot import name tokenize
Suggestions on how to fix this would be greatly appreciated. Thanks
I solve this problem as following reference link. It seems that the Python installer sometimes can't create proper registry entries in Win7 environment, users need to create them manually.
Ref link:http://www.fbagirov.com/2012/10/13/installing-nltk-for-python/
I solved this by creating a environment variable "PYTHONPATH" with the value of my python installation path.

Categories

Resources