Author Archives: Robins

ERROR: pygame-1.9.2-cp35-cp35m-win32.whl is not a supported wheel on this platform.

Why?

The downloaded pyGame is not compatible with the python version.

How do you do it?

Go to the website and download the pyGame installation related to your Python version.
(check your Python version: if you enter Python in CMD, you will be prompted for the python version.)

Process:

When installing pyGame last night, I went to the website: link according to the process in the textbook “Python Programming: from introduction to practice”, and downloaded the corresponding pyGame. However, the above errors occurred during the installation.
Looking all over the network, there is no suitable solution for me.
Then I look at the error report carefully:
pygame-1.9.2-cp35-cp35m-win32.whl is not supported by this platform (wheel, please point out what it is). The previous file is used to install pyGame.
1.9.2 refers to PIP version.
Cp35 refers to Python version 3.5, while mine is 3.7.
So far, the event is clear. Each pyGame corresponds to a different version of Python. The version is incompatible and an error is reported.
After downloading, the installation is successful!
(no screenshots here: I forgot to cut them last night)

File “manage.py“, line 17 ) from exc ^ SyntaxError: invalid syntax

The newly created Django project will run directly after entering

python manage.py runserver

The mistakes are as follows:

user@UserdeMacBook-Pro djangoProject % python manage.py runserver
  File "manage.py", line 17
    ) from exc
         ^
SyntaxError: invalid syntax

I feel a little puzzled. Later, I found that there was a problem with the specification of the python version. I should specify the python 3 version

python3 manage.py runserver

That’s it.

Python error type error: ‘range’ object does not support item assignment, solution

1. Examples are as follows:

from math import sqrt
if __name__ == '__main__':
    N = 100
    a = range(0,N)
    for i in range(2,int(sqrt(N))):
        for j in range(i + 1,N):
            if (a[i] != 0) and (a[j] != 0):
                if a[j] % a[i] == 0:
                        a[j]= 0

    for i in range(2,N):
        if a[i] != 0:
            print ("%5d" % a[i])
            if (i - 2) % 10 == 0:
                print         

Error after execution: typeerror: ‘range’ object does not support item assignment

2. The reasons for the error are as follows:

Try to use range()
to create an integer list (leading to “typeerror: ‘range’ object does not support item assignment”). Sometimes you want to get an ordered integer list, so range() seems to be a good way to generate this list. However, you need to remember that range () returns the “range object” instead of the actual list value.

3. Solutions:

Just change the code of the above example: a = range (0, n) to a = list (range (0, n))!

Solve the problem of multiple root tags in as

In as, multiple root tags usually appear when a piece of code is copied to another space

In the first case, the root tag of the original code is copied when the code is copied. In the second case, the code is not put into a package in another space to check whether the package in another space covers the new code

data argument can’t be an iterator

 b = map(ct,data.as_matrix())

data = pd.DataFrame(b).fillna(0)
Traceback (most recent call last):

  File "<ipython-input-47-48b397cc2c53>", line 1, in <module>
    data = pd.DataFrame(b).fillna(0)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 389, in __init__
    raise TypeError("data argument can't be an iterator")

TypeError: data argument can't be an iterator

Reason: Elements in a dataframe cannot be iterative.

b = map(ct,data.as_matrix())
c = list(b)
data = pd.DataFrame(c).fillna(0)

Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte solution

The Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte appears in the process of using Python 3 to read files on Mac OS.

The reason is: OS X system has hidden file. DS in the folder_ Store file, affecting the file read.

.DS_ Store is a hidden file that stores the custom properties of a folder on Mac OS, such as its icon location or background color.

The solution is: use the command line to enter the folder where the file is read and delete. DS_ Store file.

1. Use the command LS – A to view. DS_ Store file

2. rm .DS_ Store。

 

pyspark : NameError: name ‘spark’ is not defined

This is because there is no default in Python program pyspark.sql.session . sparksession , so we just need to import the relevant modules and then convert them to sparksession .
Related codes:

from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
sc = SparkContext('local')
spark = SparkSession(sc)
print(type(spark))

Print out its type and solve it successfully:
& lt; class' pyspark.sql.session .SparkSession'>

Assignment under multiple single edges is not supported for synthesis

Pay attention to check the error prompts, which will generally tell you where to find the reason. Assignment under multiple single edges is not supported

Let’s look at your code. Where is edge related? (posedge sclk or posedge reset)

That’s how we usually use it,

always @ (posedge clk or posedge reset) 

if (reset == 1’b1)

….

else

Reset is the reset signal,

If your code doesn’t have the following reset part, it will think that this is a clock sampling, and multiple clocks will take the same data, so it will report an error.

ImportError: No module named indexes.base

The problem recurred

When I use pickle to reload data, all the errors are as follows:

Traceback (most recent call last):
  File "segment.py", line 17, in <module>
    word2id = pickle.load(pk)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1378, in load
    return Unpickler(file).load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1090, in load_global
    klass = self.find_class(module, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1124, in find_class
    __import__(module)
ImportError: No module named indexes.base

The reason for this

The same code and data run on two different machines. At first, I thought the wrong machine was missing some Python packages. But there are too many packages to install, so I can’t try them one by one. Fortunately, I use virsualenv to copy the environment from another machine to this machine directly. After running, there is no problem. But in order to find out which Python installation package is missing, I use the original compilation environment, reuse pickle to generate the original data to be loaded, and then reload it At this time, there was no error.

summary

To sum up, the reason is that the original version of panda used in the generation of pickle file is different from the current version of load pickle file. So whether it is to write code in Python or other languages, the compiling environment is very important. Once the version of a package is different, it may also lead to program errors.

Arrow function should not return assignment no-return-assign

Arrow function should not return assignment no return assignment.

This paper describes the problems encountered in learning p221 of the latest Vue and vuejs in 2019, from introduction to mastery. Because the checking code of eslint is referenced, the checking error is reported. There is no problem with the code, it is the problem of eslint checking.
Solutions: 1. Remove eslint
2. Modify the code to conform to eslint
original code

   if (this.isSelectAll) {
        this.cartList.forEach(item => item.checked = false)
      } else {
        this.cartList.forEach(item => item.checked = true)
      }

Changed code

   if (this.isSelectAll) {
        this.cartList.forEach(item => { item.checked = false })
      } else {
        this.cartList.forEach(item => { item.checked = true })
      }

After learning the arrow function, we can know that the {} added can be omitted, but the rule of eslint requires this.