Tag Archives: anaconda

AttributeError: module ‘pkg_resources‘ has no attribute ‘declare_namespace‘

Record a problem. Anaconda3 CONDA version 4.6.7 is installed NB_ CONDA failed and damaged the original environment, resulting in an error as shown in the title.

It is speculated that there is a problem with the dependency. First, check the piptree and find that all dependencies are satisfied. However, I manually updated setuptools during the process of CONDA update CONDA. Although the update of CONDA update CONDA failed, the version of setuptools has been updated to 58.0.0,

– setuptools [required: >=36, installed: 58.0.0]

The highest requirement is only 36. It is suspected that the version is too new and the old version is not compatible. Then I tried the degraded version

pip uninstall setuptools

pip install setuptools==36.0.2

Problem solving.

[Solved] Jupyter Kernel error: kernel Cannot Connect—-import win32api; ImportError: DLL load failed…

The kernel is not connected

Error original

Traceback (most recent call last):
  File "D:\Anaconda\envs\tf2\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Anaconda\envs\tf2\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "D:\Anaconda\envs\tf2\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
    app.initialize(argv)
  File "D:\Anaconda\envs\tf2\lib\site-packages\traitlets\config\application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel\kernelapp.py", line 625, in initialize
    self.write_connection_file()
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel\kernelapp.py", line 236, in write_connection_file
    iopub_port=self.iopub_port, control_port=self.control_port)
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
    with secure_write(fname) as f:
  File "D:\Anaconda\envs\tf2\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
    win32_restrict_file_to_user(fname)
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed: 找不到指定的程序。
[I 16:31:42.557 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\YJF\\AppData\\Roaming\\jupyter\\runtime\\kernel-edcd3c8f-6a6b-4512-a376-4a71c0a0b1d5.json'
Traceback (most recent call last):
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel\kernelapp.py", line 261, in init_connection_file
    self.load_connection_file()
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_client\connect.py", line 494, in load_connection_file
    info = json.load(f)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 16:31:45.568 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\YJF\\AppData\\Roaming\\jupyter\\runtime\\kernel-edcd3c8f-6a6b-4512-a376-4a71c0a0b1d5.json'
Traceback (most recent call last):
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel\kernelapp.py", line 261, in init_connection_file
    self.load_connection_file()
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_client\connect.py", line 494, in load_connection_file
    info = json.load(f)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 16:31:48.584 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\YJF\\AppData\\Roaming\\jupyter\\runtime\\kernel-edcd3c8f-6a6b-4512-a376-4a71c0a0b1d5.json'
Traceback (most recent call last):
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel\kernelapp.py", line 261, in init_connection_file
    self.load_connection_file()
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_client\connect.py", line 494, in load_connection_file
    info = json.load(f)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 16:31:51.595 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\YJF\\AppData\\Roaming\\jupyter\\runtime\\kernel-edcd3c8f-6a6b-4512-a376-4a71c0a0b1d5.json'
Traceback (most recent call last):
  File "D:\Anaconda\envs\tf2\lib\site-packages\ipykernel\kernelapp.py", line 261, in init_connection_file
    self.load_connection_file()
  File "D:\Anaconda\envs\tf2\lib\site-packages\jupyter_client\connect.py", line 494, in load_connection_file
    info = json.load(f)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "D:\Anaconda\envs\tf2\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Anaconda\envs\tf2\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[W 16:31:54.603 NotebookApp] KernelRestarter: restart failed
[W 16:31:54.603 NotebookApp] Kernel edcd3c8f-6a6b-4512-a376-4a71c0a0b1d5 died, removing from map.
[W 16:32:22.967 NotebookApp] Config option `template_path` not recognized by `ExporterCollapsibleHeadings`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:22.977 NotebookApp] Config option `template_path` not recognized by `ExporterCollapsibleHeadings`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.024 NotebookApp] Config option `template_path` not recognized by `TocExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.031 NotebookApp] Config option `template_path` not recognized by `TocExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.052 NotebookApp] Config option `template_path` not recognized by `LenvsHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.062 NotebookApp] Config option `template_path` not recognized by `LenvsHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.088 NotebookApp] Config option `template_path` not recognized by `LenvsTocHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.098 NotebookApp] Config option `template_path` not recognized by `LenvsTocHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.151 NotebookApp] Config option `template_path` not recognized by `LenvsLatexExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.157 NotebookApp] Config option `template_path` not recognized by `LenvsLatexExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.380 NotebookApp] Config option `template_path` not recognized by `LenvsSlidesExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.388 NotebookApp] Config option `template_path` not recognized by `LenvsSlidesExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.515 NotebookApp] Config option `template_path` not recognized by `ExporterCollapsibleHeadings`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.523 NotebookApp] Config option `template_path` not recognized by `ExporterCollapsibleHeadings`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.570 NotebookApp] Config option `template_path` not recognized by `TocExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.577 NotebookApp] Config option `template_path` not recognized by `TocExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.598 NotebookApp] Config option `template_path` not recognized by `LenvsHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.609 NotebookApp] Config option `template_path` not recognized by `LenvsHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.633 NotebookApp] Config option `template_path` not recognized by `LenvsTocHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.643 NotebookApp] Config option `template_path` not recognized by `LenvsTocHTMLExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.694 NotebookApp] Config option `template_path` not recognized by `LenvsLatexExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.700 NotebookApp] Config option `template_path` not recognized by `LenvsLatexExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.921 NotebookApp] Config option `template_path` not recognized by `LenvsSlidesExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?
[W 16:32:23.928 NotebookApp] Config option `template_path` not recognized by `LenvsSlidesExporter`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?

Error reporting reason

    import win32api
ImportError: DLL load failed: The specified program could not be found.

This is caused by the incompatibility between the python version and the pywin32 version.

Solution:

Reinstall the latest version of pywin32 = = 301 in the TF2 environment with CONDA error. Solution: CONDA install pywin32 = = 301

[Solved] Conda Upgrade Error: PackageNotInstalledError: Package is not installed in prefix.

Use CONDA update CONDA to update CONDA. If you encounter a packagenotinstallederror problem, record it here!

Problem description

conda update –prefix /Users/omeiko/opt/miniconda3 anaconda
PackageNotInstalledError: Package is not installed in prefix.
prefix: /Users/omeiko/opt/miniconda3
package name: anaconda

When you run CONDA update, you will be prompted whether you want to run CONDA update — prefix/users/omeiko/opt/minicanda3 anaconda. After running, the above error prompt will be displayed
the reason for the problem is that you installed miniconda instead of anaconda.

 

Solution:

Method 1
execute CONDA install anaconda, install anaconda, and then run again.

Method 2
execute CONDA update — prefix/users/omeiko/opt/miniconda3 CONDA. There is no need to update anaconda
or execute CONDA update — name base CONDA (I solved it myself with this command) to update the base command

Terminal appears after anconda is installed on MAC (base)

After MAC reinstalls anaconda, it is found that each time terminal is opened, anconda’s environment is started by default. However, I don’t want to use anconda’s environment by default, as shown in the following figure.

The closing method is as follows

Method 1:

Every time you exit the base environment through CONDA deactivate on the command line, return to the automatic environment of the system

Method 2

1. By setting Auto_ activate_ Set the base parameter to false to implement:

conda config --set auto_activate_base false

2. If you want to enter, you can use CONDA activate base

3. If you go back and hope to keep it all the time, pass

conda config --set auto_activate_base true

recovery

[Solved] Ubuntu18.04 Install pyqt5 error: Command “python setup.py egg_info“ failed with error code 1 in /tmp/pip-build-92

Error in installing pyqt5 on Ubuntu 18.04:
command “Python setup.py egg”_ info” failed with error code 1 in /tmp/pip-build-92ggdywh/PyQt5/

As a result, the version of PIP is too low. The default system version is pip9, so we need to update the PIP version
the update method is as follows:

python3 -m pip install --upgrade pip

Because most of the time, we install python, or apt install Python directly, resulting in the installation of python2.7. If you just want to use a version of python, such as python3, you can uninstall python2. It’s better to uninstall to avoid conflicts.

AttributeError: module ‘keras.backend‘ has no attribute ‘eager‘

Project scenario:

under Windows environment, python 3.6, the versions of each CONDA package are as follows 0

\# Name                    Version                   Build  Channel
absl-py                   0.13.0                    <pip>
astor                     0.8.1                     <pip>
cached-property           1.5.2                     <pip>
certifi                   2021.5.30        py36ha15d459_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
cycler                    0.10.0                    <pip>
dataclasses               0.8                       <pip>
gast                      0.2.2                     <pip>
google-pasta              0.2.0                     <pip>
grpcio                    1.38.1                    <pip>
h5py                      3.1.0                     <pip>
importlib-metadata        4.6.0                     <pip>
joblib                    1.0.1                     <pip>
Keras                     2.3.1                     <pip>
Keras-Applications        1.0.8                     <pip>
Keras-Preprocessing       1.1.2                     <pip>
kiwisolver                1.3.1                     <pip>
Markdown                  3.3.4                     <pip>
matplotlib                3.3.4                     <pip>
numpy                     1.19.5                    <pip>
opt-einsum                3.3.0                     <pip>
pandas                    1.1.5                     <pip>
Pillow                    8.2.0                     <pip>
pip                       21.1.3             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
protobuf                  3.17.3                    <pip>
pyparsing                 2.4.7                     <pip>
python                    3.6.13          h39d44d4_0_cpython    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python-dateutil           2.8.1                     <pip>
python_abi                3.6                     2_cp36m    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pytz                      2021.1                    <pip>
PyYAML                    5.4.1                     <pip>
scikit-learn              0.24.2                    <pip>
scipy                     1.5.4                     <pip>
seaborn                   0.11.1                    <pip>
setuptools                49.6.0           py36ha15d459_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
six                       1.16.0                    <pip>
sklearn                   0.0                       <pip>
tensorboard               1.15.0                    <pip>
tensorflow                1.15.0                    <pip>
tensorflow-estimator      1.15.1                    <pip>
termcolor                 1.1.0                     <pip>
threadpoolctl             2.1.0                     <pip>
typing-extensions         3.10.0.0                  <pip>
ucrt                      10.0.20348.0         h57928b3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vc                        14.2                 hb210afc_5    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vs2015_runtime            14.29.30037          h902a5da_5    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
Werkzeug                  2.0.1                     <pip>
wheel                     0.36.2             pyhd3deb0d_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
wincertstore              0.2             py36ha15d459_1006    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
wrapt                     1.12.1                    <pip>
zipp                      3.4.1                     <pip>

Problem Description:

it seems that the version of the library that has been adjusted for a long time has finally run through a LSTM demo, but if you want to open a new test file for testing, the following problems appear


Solution:

the solution to stackoverflow is to use the current keras library and tensorflow Library of unitall, because the higher version of keras library may be used, but the running code is of lower version. Note that you need to install tensorflow before installing keras

The specific steps of stackoverflow with the most likes are as follows:
delete tenorflow delete tenorflow

pip uninstall tensorflow

Update PIP version

pip install --upgrade pip

install keras

pip install Keras

install tensorflow

pip install tensorflow

Apart from this method, I want to say that my final solution is: I found the import statement of the keras library

from keras.models import Sequential
from keras.layers import LSTM, Dense, Activation

Cannot appear in two. Py files!!! Even if you just don’t use import, you will still report this error. It’s too bad. I found this problem after reloading it, so when testing the code, you should either create a new project or write the import statement in a file.

The python version output from the command line is inconsistent with the python version in the current CONDA environment

Record a strange little problem.

         In order to complete the emotional dialogue project arranged by my tutor, I found a model from GitHub, and then configured the environment python2.7 + tensorflow1.13.1 on the server according to readme. At the beginning of training, I found that the training speed was very slow. After checking, I found that I didn’t use the GPU version of tensorflow, so I changed it to tensorflow-gpu1.13.1.

         Import error: libcublas. So. 10.0: cannot open shared object file: no such file or directory

         Very common old problem, CUDA is not installed or environment variables are not configured. I didn’t add CUDA to the environment variable here, because it’s a server in the school laboratory. It doesn’t have sudo permission and can’t modify the environment variable of the system, so I can only add the environment variable I need with the export command every time I start the terminal. For convenience, all the environment variables that need to be exported are recorded in a file. You only need the file source each time.

        After the source is completed, a strange problem appears. I output Python 3.8.5 with Python command in CONDA environment, and the python version of the environment shown in CONDA list is 2.7, as shown in the figure below. Clearly is the environment of Python 2.7, why use the python command to prompt that the current version is Python 3.8.5?I try to import tensorflow. It also prompts no module named tensorflow, which means that although it shows that I am in the dual RL master environment, I am in another environment?

         I repeatedly tried to delete the environment, create a new environment, and re install various packages. After many tests, I finally found the problem. When CONDA activate is executed, the target environment will be added to the environment variable of the current system, so when the python command is executed on the command line, the python version in the target environment will be executed. When the export command is executed, the specified environment variable will be added to the system environment variable. When the variable name is repeated, the existing environment variable will be overridden. When I use source to execute files containing many export commands, one of the export commands adds the default Python version of CONDA to the environment variables of the system, which covers the python version I activated with CONDA before. Therefore, although my CONDA shows that the python version I used is 2.7, the environment variables of the system have been covered by the export command I used later, The default version of Python is 3.8.5.

        I tested again. First add a python version to the environment variable by using export, and then use CONDA activate to activate another version of Python. Using Python on the command line, you will find that the output is the later version of Python. Therefore, you can conclude that the one added after the same variable name in the environment variable will override the existing one.

         Although it’s not a big problem, sometimes it’s this kind of energy-saving twig that keeps you from finding mistakes.

RuntimeError: implement_array_function method already has a docstring(Pycharm install package error)

Recently, I’m writing the course of financial analysis and prediction in Python. Because I’m lazy, I didn’t match the required Library under CONDA in advance. Using pychar install package directly will lead to some version incompatibility and mismatching due to the installation sequence, which leads to
runtimeerror: implementation_ array_ Function method already has a docstring
error report
mark
I don’t know what I’m writing<
PIP universal pandas
PIP universal mattlotlib
PIP universal Skippy
PIP universal numpy
PIP universal scikit learn
then install
PIP install numpy
PIP install Skippy
PIP install panda
PIP install mattlotlib
pip install scikit learn
in the following order

Anaconda Matplotlib drawing Chinese garbled solution

I found a lot of methods to solve the Chinese garbled code of Matplotlib in Anaconda on the Internet. I feel it is not concise enough. Now let’s make a summary. Two steps, one is to find the font, the other is to set it.

1. Font

The system font file is usually saved in the   C:\Windows\Fonts

Open copy any font:

Save it in the TTF folder. Lu Jin’s name is e::’anaconda ‘,’lib’,’site-packages’,’matplotlib ‘,’mpl-data’,’fonts’,’ttf ‘

You can change the file name of Anaconda installed on your computer, and the following path is the same.

So the font is chosen.

2. Setting

Go back to MPL data and open the matplotlibrc file: e:// Anaconda/lib/site packages/Matplotlib/MPL data

Notepad shows about 249 lines, the upper middle part of the file:

Remove the comment in front of font. Family, and then change the following name to the newly copied font name: simhei.

Save with Ctrl + s and reopen the compiler.

FileNotFoundError: Could not find module ‘D:\Anaconda3\envs\labe\Library\bin\geos_c.dll‘ [Solved]

Solution:
FileNotFoundError: Could not find module
‘D:\Anaconda3\envs\LabelImg\label\bin\geos_c.dll’ (or one of its dependencies).
Try using the full path with constructor syntax.(or one of its dependencies). Try using the full path with constructor syntax.

1, most people are not importing the “shapely” dependency. You only need to import it

pip install shapely

2. Import this or report an error, basically it is wrong with your Python version.

To download the corresponding. WHL file, the link is as follows: https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely , after entering the website, Ctrl + F can find shapely, and select the version up or down according to your own version( The author is python3.8)

#First uninstall the downloaded shapely
pip uninstall shapely
#then download the local cp38 version of shapely
pip install D:\PyCharm\Pro\OCR\PaddleOCR\PPOCRLabel\BACK\Shapely-1.7.1-cp38-cp38-win_amd64.whl