unable to start Anaconda in Windows - python-3.x

I am unable to start anaconda environment after installing some updates following is the error that I get in command prompt
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\MOHIT>conda
Traceback (most recent call last):
File "C:\Users\MOHIT\Anaconda3\Scripts\conda-script.py", line 3, in <module>
import conda.cli
File "C:\Users\MOHIT\Anaconda3\lib\site-packages\conda\cli\__init__.py", line 8, in <module>
from .main import main # NOQA
File "C:\Users\MOHIT\Anaconda3\lib\site-packages\conda\cli\main.py", line 40, in <module>
import importlib
File "C:\Users\MOHIT\Anaconda3\lib\importlib\__init__.py", line 57, in <module>
import types
File "C:\Users\MOHIT\Anaconda3\lib\types.py", line 166, in <module>
import functools as _functools
File "C:\Users\MOHIT\Anaconda3\lib\functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "C:\Users\MOHIT\Anaconda3\lib\weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
C:\Users\MOHIT>
Please help.

When installing conda make sure to UNCHECK "Register Anaconda as the system Python x.x" as shown in the MinicondaInstaller.
Otherwise everything becomes meaningless and you wonder why is this happening to you and you cry a little.
I don't know why this solved the problem for me, but I think it has something to do with keeping your system python and your virtual env python separate. Took me a whole day of work just to debug it.

Related

OSError: [WinError 126] while importing seaborn package

I got an example project from my friend that uses seaborn package to draw maps. I've opened project in pycharm, created venv, installed all needed packages and tried to run his code. Unfortunately code returns an error while importing package seaborn:
Traceback (most recent call last):
File "C:/Users/Carlito/Desktop/Maps/map.py", line 6, in <module>
from seaborn import set
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\rcmod.py", line 7, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\palettes.py", line 9, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\utils.py", line 6, in <module>
from scipy import stats
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\scipy\__init__.py", line 136, in <module>
from . import _distributor_init
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126]
I have tried manually installing all dependencies of this package but it didn't work. These are packages that I've installed:
One maybe important detail, my friend uses Linux Mint, while I am trying to run the project on Windows 10.
Anyone knows what is going on here?
More info required, give this a try
Check for paths hardcoded and try changing to windows backslashes
Example
Here the filepath is given C:/Users/Carlito/Desktop/Maps/map.py, which is Linux , try
Windows
C:\Users\Carlito\Desktop\Maps\map.py
C:\\Users\\Carlito\\Desktop\\Maps\\map.py

distutils.util missing after upgrading to 3.8

I just upgraded to Pop OS(Ubuntu) 20.04, which upgraded Python 3.7 to 3.8. Now I get this error below when I run sam (from the AWS SAM CLI). Solutions found online all had to do with making sure python3-distutils is installed. I have verified that python3-disutils is installed. /usr/lib/python3.8/distutils looks fine, just not getting picked up for some reason.
One thing I noticed is that in the traceback below, it's using the system-wide pip, while I have a later version of pip installed under my .local. I don't know if those two symptoms are related but looks like I'm missing some config somewhere so none of the 3.8 or user space stuff is picked up.
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pip/_internal/main.py", line 14, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/lib/python3/dist-packages/pip/_internal/utils/entrypoints.py", line 3, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
I have the same issue on Debian Bullseye (or rather mixed Bullseye/Buster).
Package python3-distutils (3.8.6) contains module for Python 3.8 and 3.9 (!).
Old package (3.7.3) for Python 3.7. You have to choose.
My workaround is just copy module.
mkdir -p /usr/lib/python3.7/distutils
cp -a /usr/lib/python3.8/distutils/* /usr/lib/python3.7/distutils/

Systrace by Command Line error

i am trying to use of systrace. for this, i am reading official site.
but after run this command on terminal :
D:\Software\Android\android-sdk\platform-tools\systrace>python systrace.py --time=10 -o mynewtrace.html sched gfx view wm
I got these error:
Traceback (most recent call last):
File "systrace.py", line 48, in <module>
from systrace import run_systrace
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\systrace\systrace\run_systrace.py", line 40, in <module>
from devil import devil_env
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\systrace\systrace\..\..\devil\devil\devil_env.py", line 32, in <module>
import dependency_manager # pylint: disable=import-error
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\dependency_manager\dependency_manager\__init__.py", line 28, in <module>
from .archive_info import ArchiveInfo
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\dependency_manager\dependency_manager\archive_info.py", line 7, in <module>
from dependency_manager import exceptions
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\dependency_manager\dependency_manager\exceptions.py", line 5, in <module>
from py_utils import cloud_storage
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\common\py_utils\py_utils\cloud_storage.py", line 20, in <module>
from py_utils import lock
File "D:\Software\Android\android-sdk\platform-tools\systrace\catapult\common\py_utils\py_utils\lock.py", line 18, in <module>
import win32con # pylint: disable=import-error
ImportError: No module named win32con
my python version:
D:\Software\Android\android-sdk\platform-tools\systrace>python --version
Python 2.7.13
D:\Software\Android\android-sdk\platform-tools\systrace>
I have added python PATH to ** system ENVIRONMENT** . my main goal of use Systrace by command is using of Tracing Application Code. I put:
Trace.beginSection("MyAdapter.onCreateViewHolder");
and
Trace.endSection();
to my code and i want to see this output as a trace to systrace by -a or --app= options.
GUI systrace is ok on google chrome and work excellent in this browser.
python doesn't come with pywin32 library. you just need to download pywin32 version according to your system from here https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/ and install it. It will work.
For me, running
pip install pypiwin32
fixed the problem
My error stacktrace
C:\Users\hhh\AppData\Local\Android\Sdk\platform-tools\systrace>python
systrace.py --time=10 -o my_systrace.html Traceback (most recent call
last): File "systrace.py", line 48, in <module>
from systrace import run_systrace File "C:\Users\hhh\AppData\Local\Android\Sdk\platform-tools\systrace\catapult\systrace\systrace\run_systrace.py",
line 43, in <module>
from systrace import systrace_runner File "C:\Users\hhh\AppData\Local\Android\Sdk\platform-tools\systrace\catapult\systrace\systrace\systrace_runner.py",
line 11, in <module>
from systrace import output_generator File "C:\Users\hhh\AppData\Local\Android\Sdk\platform-tools\systrace\catapult\systrace\systrace\output_generator.py",
line 15, in <module>
from tracing.trace_data import trace_data File "C:\Users\hhh\AppData\Local\Android\Sdk\platform-tools\systrace\catapult\tracing\tracing\trace_data\trace_data.py",
line 17, in <module>
import six ImportError: No module named six
I solved the problem:
pip install six
summary
find ImportError what, use pip install it
In Windows10 when running through the command line, I got the same errors!
But if run systrace from Android Device Monitor all work fine!
To do this:
run Android Device Monitor
click DDMS icon
in the "Devices" tab select your device
click "Capture system wide trace using Android systrace" (Near the icon " Screen Capture")
I use Android Device Monitor Version: 25.2.2
In my case I was using Python 3.8, I just switched to 2.7.

error of import scipy.stats for windows 7

I use windows 7 and installed python 3.5 32bit. I installed numpy 1.11 + mkl win32 whl version for python 3.5 from http://www.lfd.uci.edu/~gohlke/pythonlibs/
and installed scipy 0.17.0 from the same site same way. I use pip install. No problem import numpy and scipy, but see error when import scipy.stats or from scipy import stats, etc... Here is the error message:
if from scipy import stats:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from scipy import stats
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\stats\__init__.py", line 338, in <module>
from .stats import *
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\stats\stats.py", line 180, in <module>
import scipy.special as special
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\special\__init__.py", line 627, in <module>
from ._ufuncs import *
File "scipy\special\_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:26242)
ImportError: DLL load failed: The specified module could not be found.
If use import scipy.stats see below error message:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import scipy.stats
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\stats\__init__.py", line 338, in <module>
from .stats import *
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\stats\stats.py", line 180, in <module>
import scipy.special as special
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\special\__init__.py", line 629, in <module>
from .basic import *
File "C:\Programs\Python\Python35-32\lib\site-packages\scipy\special\basic.py", line 14, in <module>
from ._ufuncs import (ellipkm1, mathieu_a, mathieu_b, iv, jv, gamma, psi, zeta,
ImportError: cannot import name 'ellipkm1'
I have searched for solution from websites but could not find an answer. Please help. This is really frustrating...
Thanks
Rocky
Ok, finally I solved this myself. At the beginning I knew I needed the 2015 visual C++ redistribution and had it installed, the problem is I installed the 64bit one while obviously I should have used 32 bit one since my python and numpy, scipy were all 32 bit.
Hope this helps for other people

Pyexpat import error when running aws cli

I am having some problems running the aws cli on ubuntu 14.04
I keep getting the following error
Traceback (most recent call last):
File "/usr/local/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 16, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 27, in <module>
import botocore.credentials
File "/usr/local/lib/python2.7/dist-packages/botocore/credentials.py", line 23, in <module>
from botocore.compat import total_seconds
File "/usr/local/lib/python2.7/dist-packages/botocore/compat.py", line 118, in <module>
import xml.etree.cElementTree
File "/usr/lib/python2.7/xml/etree/cElementTree.py", line 3, in <module>
from _elementtree import *
ImportError: PyCapsule_Import could not import module "pyexpat"
When I do
ls -l /usr/lib/python2.7/*/pyexpat*
I get
-rw-r--r-- 1 root root 69200 Mar 23 01:57 /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
Any help is much appreciated.
EDIT
Somehow the problem was I had to run the aws commands with sudo.
I came across similar problem when I did xml parsing in Python (2.7). Finally, it was figured out that it was caused by the inaccurately defined LD_LIBRARY_PATH environment variable. Here was my situation: the xml parsing library: libexpat.so was confused with the MATLAB version (libexpat.so.1.5.0) between the system version (libexpat.so.1.6.0), the ImportError arose when loaded the MATLAB version libexpat.so, after I precisely defined the LD_LIBRARY_PATH, that is excluding MATLAB library path, everything went smoothly.

Resources