Category Archives: Python

[Solved] Conda install Error: An HTTP error occurred when trying to retrieve this URL. HTTP errors are often…

1. Problem Description: prepare to execute the following command in Anaconda prompt:

conda install -c stellargraph stellargraph

An HTTP error occurred when trying to retrieve this URL

HTTP errors are often intermittent, and a simple retry will get you on your way.

2. Solution: open “C:\users\your computer name\condarc

Delete all lines in condarc, copy and paste the following code, and then save:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true
ssl_verify: true

(anyway, I can finally succeed in this file with the above code. I don’t know if you can do it.

3. Re run

conda install -c stellargraph stellargraph
    1. as long as you don’t report an error (try it several times, it may not work well). Maybe it will take a long time. Please be patient. If you want to improve the speed, you’d better create a new virtual environment and install the software, which will be much faster

Create a new environment ( CONDA env create - n env_name ) and install the software. In this way, the compatibility with the existing software will not be considered. It can also greatly reduce the search space and improve the speed of resolving software dependencies.

[Solved] ERROR: Cannot uninstall ‘wrapt‘. It is a distutils installed project and thus we cannot accurately d

ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Problem Description.
When installing tensorflow, an error is reported: “ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.”

pip install tensorflow==1.15.0

Solution:

Change the command to:

pip install tensorflow==1.15.0 --ignore-installed wrapt

[Solved] ERROR: pip‘s dependency resolver does not currently take into account all the packages that are inst

When installing wrapt, the following error is reported:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.7.0 requires h5py>=2.9.0, which is not installed.
tensorflow 2.7.0 requires typing-extensions>=3.6.6, which is not installed.
tensorflow 2.7.0 requires wheel<1.0,>=0.32.0, which is not installed.

Just follow the prompts

pip install h5py
pip install typing-extensions
pip install wheel

[Solved] SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)

Run Django with pycharm, python manage Py runserver error

Checked the Internet and said to put widgets Delete the comma in line 152 of Py, which may be a compatibility problem between Python and Django. Try it. You can click the hyperlink above. Pycharm can quickly open the document, and then find the widgets under admin Py file is OK, because the prompt says form Django contrib. Admin import helpers, widgets, and options The PY file is in the admin directory.

odoo Error: KeyError:‘ir.http‘ [How to Solve]

#####1 an error occurred while loading odoo


######2 first check the configuration file, especially the path

######3, and then enter – I base – D new database name in run/debug configurations

#####4 restart the server to see if it is OK. If not, reinstall the database and change the version of the database. If not, reload the source code. The source code may have been accidentally changed

After reading, remember to like it, refill

[Solved] python tqdm raise RuntimeError(“cannot join current thread“) RuntimeError: cannot join current thr

The following error occurred when using tqdm today:

Exception ignored in: <function tqdm.__del__ at 0x7f78f8445320>
Traceback (most recent call last):
  File "/root/anaconda3/lib/python3.7/site-packages/tqdm/_tqdm.py", line 931, in __del__
    self.close()
  File "/root/anaconda3/lib/python3.7/site-packages/tqdm/_tqdm.py", line 1133, in close
    self._decr_instances(self)
  File "/root/anaconda3/lib/python3.7/site-packages/tqdm/_tqdm.py", line 496, in _decr_instances
    cls.monitor.exit()
  File "/root/anaconda3/lib/python3.7/site-packages/tqdm/_monitor.py", line 52, in exit
    self.join()
  File "/root/anaconda3/lib/python3.7/threading.py", line 1041, in join
    raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread

I didn’t expect tqdm to have a bug

Solution:

pip install tqdm --upgrade

Python Use PIP to install pyinstaller Error [Solved]

1. Error reporting using pip

D:\date\IDEA\Game\PyInstaller-3.4>pip install pyinstaller
'pip' is not an internal or external command, nor is it a runnable program
or batch file.

Solution: add environment variables

Add new system variables.
Variable name: PYTHON_HOME
Variable value: D:\software\anaconda3\Scripts
Modify the path variable.
	Add:%PYTHON_HOME%

2. Error when installing pyinstaller with PIP

D:\date\IDEA\Game\PyInstaller-3.4>pip install pyinstaller
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pyinstaller/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pyinstaller/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pyinstaller (from versions: none)
ERROR: No matching distribution found for pyinstaller
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

Solution: add trust source

D:\date\IDEA\Game\PyInstaller-3.4>pip install  pyinstaller  --index-url http://pypi.douban.com/simple/    --trusted-host pypi.douban.com
Looking in indexes: http://pypi.douban.com/simple/
Collecting pyinstaller
  Downloading http://pypi.doubanio.com/packages/da/98/ba0071620a2bd672cd98b398653517a296f988a8271d9d2f365a7922a51b/pyinstaller-4.7-py3-none-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 2.2 MB/s
Requirement already satisfied: pywin32-ctypes>=0.2.0 in d:\software\anaconda3\lib\site-packages (from pyinstaller) (0.2.0)
Collecting pyinstaller-hooks-contrib>=2020.6
  Downloading http://pypi.doubanio.com/packages/80/74/4c885df43604c4ae570610e187052f29d806d582e398c2e48b83dad74610/pyinstaller_hooks_contrib-2021.4-py2.py3-none-any.whl (215 kB)
     |████████████████████████████████| 215 kB ...
Collecting pefile>=2017.8.1
  Downloading http://pypi.doubanio.com/packages/ee/e1/a7bd302cf5f74547431b4e9b206dbef782d112df6b531f193bb4a29fb1b9/pefile-2021.9.3.tar.gz (72 kB)
     |████████████████████████████████| 72 kB ...
Collecting altgraph
  Downloading http://pypi.doubanio.com/packages/84/3f/1a5c9bef54cac9bf41edd6f4aaf61cd52ed578e10ccc607e0278012cb4a5/altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
Requirement already satisfied: setuptools in d:\software\anaconda3\lib\site-packages (from pyinstaller) (58.0.4)
Requirement already satisfied: future in d:\software\anaconda3\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.18.2)
Building wheels for collected packages: pefile
  Building wheel for pefile (setup.py) ... done
  Created wheel for pefile: filename=pefile-2021.9.3-py3-none-any.whl size=68844 sha256=139bf21106643db9019b3f0c33e2da41e2bda609170130bb24491cf1a5eeba0a
  Stored in directory: c:\users\edz\appdata\local\pip\cache\wheels\7b\f8\a2\c28c8f2797bf32ae30e18da14e5a5ab9cfbfb72da03593426d
Successfully built pefile
Installing collected packages: pyinstaller-hooks-contrib, pefile, altgraph, pyinstaller
Successfully installed altgraph-0.17.2 pefile-2021.9.3 pyinstaller-4.7 pyinstaller-hooks-contrib-2021.4

[Solved] MAC terminal Use ‘CONDA activate’ and ‘CONDA install package_ Error reported by name’ Error

In M1 series chips, the MAC uses CONDA to switch the environment in order to directly install various libraries or other operations in the target environment. Otherwise, it is directly installed in the python environment in miniforge 3, rather than the python environment being used.


(if CONDA install package_name reports that the permission is not enough, it may be because sudo bash miniforge 3… SH is used when installing miniforge 3, that is, it is installed with the administrator’s permission) — the author’s machine is installed with sudo bash miniforge 3… Sh. here is only a record of the pit he stepped on. Using sudo CONDA install package_Name can solve the problem.


Problems encountered in configuring Python environment on macbook pro of m1pro chip:

After configuring CONDA’s Python environment, switch the environment to use

conda activate env_name #如  conda activate py39

Errors are reported as follows:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'

Solution:

Input directly at the terminal:

conda init zsh

Exit the Mac’s Zsh shell and restart. Then execute CONDA activate env_ Name.

Note: exit the current environment:

conda deactivate