Cannot install Win32GUI in Anaconda environment setup in PyCharm
Solution
in pycharm terminal execution conda install pywin32 instruction
Tag Archives: python
Python judge perfect square number
— coding: utf-8 —
# # Integer-coding:
+ 100 + 268 is a perfect square
# + coding: utf-8 —
#
from math import sqrt
def f(number):
for x in range(0,number):
m=sqrt(x+100)
n=sqrt(x+268)
if mint(m) and nint(n):
print x
If name = = “main” :
f (1000).
Running results:
21
261
[Python] error syntax error: summary of solutions to invalid syntax
Today, I learned Python, but I had a problem at the beginning. The code was perfectly fine, but every time I ran it, it showed “SyntaxError: Invalid Syntax”.
“SyntaxError: invalid syntax” means “mark> syntax error mark>;
after query solved the problem, so concluded a solution to this question:
- version problem: mark>
because python2 and python3 are incompatible, so some can run on python2 code can not run on python3; You can try to change versions; path problem: mark>
remember to take a closer look at your own path is correct; careless problem: br> f>t to add colon (:) at the end of if, elif, else, for, while, class,def declarations;
used = instead of ==; When installing third-party modules : mark>
when installing third-party modules is also likely to be “SyntaxError: invalid syntax” this problem, then need to check some is installed under the CMD window, at the same time, to the python installation directory, find PIP installation directory inside;
Solve the syntax error of Python PIP installation sys.stderr.write (f“ERROR: {exc}“)

br>
Error reported in Python reading file oserror: [errno 22] invalid argument: ‘u202ac: \ \ users \ \ yyqhk \ \ desktop \ \ 1. CSV’


It is better to search \u202a directly to find the solution, because I directly through the file properties under the safe Tab copy path, just from the write a different place to copy the path or manually enter again to solve the problem
Reference: http://blog.csdn.net/qq_33733970/article/details/77519660
Python oserror: [errno 22] invalid argument: solution
ERROR: [Errno 22] Invalid argument:
Method 1: Incorrect input format
f = open('F:\Python 3.6\test.txt','r')
It should be modified to:
f = open('f:\\Python 3.6\\test.txt','r')
Or:
f = open('f:/Python 3.6/test.txt','r')
Change \ to /, or \\, because \t is a newline character in Python and is not recognized.
Method two :(I made a mistake here)
It is best to enter the path manually rather than copy and paste the changes directly.
Python error: importerror: DLL load failed: unable to find the specified module solution
The following error is reported while using Python for a dataset:

The reason for the error
The error occurs because the corresponding module’s file is incomplete or there is no corresponding module.
The solution
The solution is as follows:
The main steps are as follows:
1. Locate the module and uninstall it with PIP. Take the example I came across:
pip uninstall numpy
2. Reinstall the module again.
pip install numpy
The point is which module is causing this problem?
We read the wrong picture:

Find the most recent import package code that reported the error, regardless of importing packages from ‘. ‘:

We found out it was NumPy and reinstalled the module.
Raspberry pie upgrade to Python 3.7.3
Install dependency packages
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev
sudo apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm
sudo apt-get install -y libncurses5-dev libncursesw5-dev xz-utils tk-dev
Find the corresponding version from the Python web page and click to download it.
sudo wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
Third, extract the
sudo tar -zxvf Python-3.7.3.tgz
Unzip it and enter the generated directory python-3.7.3
cd Python-3.7.3
Install and compile Python
sudo ./configure && sudo make && sudo make install
6. After installation, create/modify the existing soft connection.
create soft connection (first time)
sudo ln -f /usr/local/bin/python3.7 /usr/bin/python
sudo ln -f /usr/local/bin/pip3.7 /usr/bin/pip
Modify the soft connection (more than once)
sudo ln -sf /usr/local/bin/python3.7 /usr/bin/python
sudo ln -sf /usr/local/bin/pip3.7 /usr/bin/pip
Seven, print version test
python3 -V
pip3 -V
success
Implementation of screen cleaning in Python idle
screen things too much, need clear screen, window screen clearing command in Windows is CLS, in Python IDLE is the shortcut Ctrl + L
but this shortcut is not the default, need to do some operation
> Copy and save the following code into your new ClearWindow.py
"""
Clear Window Extension
Version: 0.2
Author: Roger D. Serwy
[email protected]
Date: 2009-06-14
It provides "Clear Shell Window" under "Options"
with ability to undo.
Add these lines to config-extensions.def
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
"""
class ClearWindow:
menudefs = [
('options', [None,
('Clear Shell Window', '<<clear-window>>'),
]),]
def __init__(self, editwin):
self.editwin = editwin
self.text = self.editwin.text
self.text.bind("<<clear-window>>", self.clear_window2)
self.text.bind("<<undo>>", self.undo_event) # add="+" doesn't work
def undo_event(self, event):
text = self.text
text.mark_set("iomark2", "iomark")
text.mark_set("insert2", "insert")
self.editwin.undo.undo_event(event)
# fix iomark and insert
text.mark_set("iomark", "iomark2")
text.mark_set("insert", "insert2")
text.mark_unset("iomark2")
text.mark_unset("insert2")
def clear_window2(self, event): # Alternative method
# work around the ModifiedUndoDelegator
text = self.text
text.undo_block_start()
text.mark_set("iomark2", "iomark")
text.mark_set("iomark", 1.0)
text.delete(1.0, "iomark2 linestart")
text.mark_set("iomark", "iomark2")
text.mark_unset("iomark2")
text.undo_block_stop()
if self.text.compare('insert', '<', 'iomark'):
self.text.mark_set('insert', 'end-1c')
self.editwin.set_line_and_column()
def clear_window(self, event):
# remove undo delegator
undo = self.editwin.undo
self.editwin.per.removefilter(undo)
# clear the window, but preserve current command
self.text.delete(1.0, "iomark linestart")
if self.text.compare('insert', '<', 'iomark'):
self.text.mark_set('insert', 'end-1c')
self.editwin.set_line_and_column()
# restore undo delegator
self.editwin.per.insertfilter(undo)
3, then find the config in this directory – extensions. Def this file (idle configuration file extensions), open it in notepad
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
Clear shell window Ctrl +L
br>
Python idle add configuration shortcut (Ctrl + L)
Copy the following source file ClearWindow.py into the idlelib directory.
Add configuration items to the config-extensions.def file:
The filename must be: clearwindow.py beware case! Save to directory \Python39\Lib\idlelib\.
Locate the configuration file in the \Python39\Lib\idlelib directory: config-extensions.def
Add at the end:
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=< Control-Key-l>
"""
file name must be:
ClearWindow.py
Clear Window Extension
Version: 0.2
Author: Roger D. Serwy
[email protected]
Date: 2009-06-14
It provides "Clear Shell Window" under "Options"
with ability to undo.
Add these lines to config-extensions.def
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
"""
class ClearWindow:
menudefs = [
('options', [None,
('Clear Shell Window', '<<clear-window>>'),
]),]
def __init__(self, editwin):
self.editwin = editwin
self.text = self.editwin.text
self.text.bind("<<clear-window>>", self.clear_window2)
self.text.bind("<<undo>>", self.undo_event) # add="+" doesn't work
def undo_event(self, event):
text = self.text
text.mark_set("iomark2", "iomark")
text.mark_set("insert2", "insert")
self.editwin.undo.undo_event(event)
# fix iomark and insert
text.mark_set("iomark", "iomark2")
text.mark_set("insert", "insert2")
text.mark_unset("iomark2")
text.mark_unset("insert2")
def clear_window2(self, event): # Alternative method
# work around the ModifiedUndoDelegator
text = self.text
text.undo_block_start()
text.mark_set("iomark2", "iomark")
text.mark_set("iomark", 1.0)
text.delete(1.0, "iomark2 linestart")
text.mark_set("iomark", "iomark2")
text.mark_unset("iomark2")
text.undo_block_stop()
if self.text.compare('insert', '<', 'iomark'):
self.text.mark_set('insert', 'end-1c')
self.editwin.set_line_and_column()
def clear_window(self, event):
# remove undo delegator
undo = self.editwin.undo
self.editwin.per.removefilter(undo)
# clear the window, but preserve current command
self.text.delete(1.0, "iomark linestart")
if self.text.compare('insert', '<', 'iomark'):
self.text.mark_set('insert', 'end-1c')
self.editwin.set_line_and_column()
# restore undo delegator
self.editwin.per.insertfilter(undo)
The filename must be: clearwindow.py beware case!
RemoveError: ‘requests‘ is a dependency of conda and cannot be removed from conda‘s operating env
1. The question is:
removeError: ‘requests’ is a dependency of Conda and cannot be removed from Conda’s operating environment.
removeError: ‘setup_tools’ is a dependency of CONDA and cannot be removed from CONDA’s operating environment.
2. Solutions
Force Conda to be updated before installation
conda update --force conda
3. More related questions
https://github.com/conda/conda/issues/8149
RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating enviro
RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating environment.
This error occurs because the ‘Requests’ package was installed with PIP and is triggered if you install other packages using CANDA.
Solutions:
1, Use PIP uninstall packagename to uninstall the package, it is not recommended to use this, it will cause other errors.
2. Use PIP packagename to install the package
Good luck
Reference:
https://blog.csdn.net/weixin_40405758/article/details/88094405