问:
python-docx import is not able to be imported even though the library is installed
System:
MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)
Processor 1.4 GHz Quad-Core Intel Core i5
Memory 16GB
OS macOs Monterey version 12.6.1

I'm still fairly new to Python and just learned about the docx library.

I get the following error in Visual Studio Code about the docx library.
Import "docx" could not be resolved.

enter image description here

When I check to see the version installed I get the following:

pip3 show python-docx
Name: python-docx
Version: 0.8.11

I am able to create Word documents with one Python script even with the import issue. However, I've tried to create one using a table and this is what is causing me issues. I'm not sure if the import issue is the root cause.

When I run my script I get the following:

python3 test.py

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/docx/styles/styles.py:139: UserWarning: style lookup by style_id is deprecated. Use style name as key instead.
return self._get_style_id_from_style(self[style_name], style_type)`

The code causing the error:

```<code>Add review question table
table = document.add_table(rows=1, cols=3)
table.style = 'TableGrid'
</code>```

In researching I found I may need to import the following:
from docx.oxml.table import CT_TableStyle

And add the following to that section:
# Add review question table
table = document.add_table(rows=1, cols=3)
style = CT_TableStyle()
style.name = 'TableGrid'
table.style = style

I now get the following warning:
Import "docx.oxml.table" could not be resolved

And the following error when running the script:

line 2, in
from docx.oxml.table import CT_TableStyle
ImportError: cannot import name 'CT_TableStyle' from 'docx.oxml.table' (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/docx/oxml/table.py)

I also created a virtual environment and still have the same issues. If you need additional details, just let me know what to provide.

Kind regards,

Marcus

Body:
System:
MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)
Processor 1.4 GHz Quad-Core Intel Core i5
Memory 16GB
OS macOs Monterey version 12.6.1

I'm still fairly new to Python and just learned about the docx library.

I get the following error in Visual Studio Code about the docx library.
Import "docx" could not be resolved.

enter image description here

When I check to see the version installed I get the following:

pip3 show python-docx
Name: python-docx
Version: 0.8.11

I am able to create Word documents with one Python script even with the import issue. However, I've tried to create one using a table and this is what is causing me issues. I'm not sure if the import issue is the root cause.

When I run my script I get the following:

python3 test.py

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/docx/styles/styles.py:139: UserWarning: style lookup by style_id is deprecated. Use style name as key instead.
return self._get_style_id_from_style(self[style_name], style_type)`

The code causing the error:

Add review question table
table = document.add_table(rows=1, cols=3)
table.style = 'TableGrid'

In researching I found I may need to import the following:
from docx.oxml.table import CT_TableStyle

And add the following to that section:
# Add review question table
table = document.add_table(rows=1, cols=3)
style = CT_TableStyle()
style.name = 'TableGrid'
table.style = style

I now get the following warning:
Import "docx.oxml.table" could not be resolved

And the following error when running the script:

line 2, in
from docx.oxml.table import CT_TableStyle
ImportError: cannot import name 'CT_TableStyle' from 'docx.oxml.table' (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/docx/oxml/table.py)

I also created a virtual environment and still have the same issues. If you need additional details, just let me know what to provide.

Kind regards,

Marcus


来源: stackexchange

问:
Could not download metadata for numpy 1.19.1 using pip
I am trying to install the dependencies necessary for a diy teaching library for machine learning engineers (Minitorch), but I get an error after it tries to install a specific version of numpy (1.19.1).

```<code>(env) C:\Users\pytho\OneDrive\Documentos\Minitorch\minitorch>python -m pip install -r requirements.txt
Collecting numpy==1.19.1
  Downloading numpy-1.19.1.zip (7.3 MB)
     ---------------------------------------- 7.3/7.3 MB 2.3 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─\> \[242 lines of output\]
Running from numpy source directory.
\<string\>:470: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
C:\\Users\\pytho\\AppData\\Local\\Temp\\pip-install-alzx9eh\_\\numpy_1923ad9693a54691aa73f3e3cd16576b\\tools\\cythonize.py:73: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
required_version = LooseVersion('0.29.21')
C:\\Users\\pytho\\AppData\\Local\\Temp\\pip-install-alzx9eh\_\\numpy_1923ad9693a54691aa73f3e3cd16576b\\tools\\cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(cython_version) \< required_version:
Processing numpy/random_bounded_integers.pxd.in
Processing numpy/random\\bit_generator.pyx
Processing numpy/random\\mtrand.pyx
Processing numpy/random_bounded_integers.pyx.in
Processing numpy/random_common.pyx
Processing numpy/random_generator.pyx
Processing numpy/random_mt19937.pyx
Processing numpy/random_pcg64.pyx
Processing numpy/random_philox.pyx
Processing numpy/random_sfc64.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
No module named 'numpy.distutils.\_msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries mkl_rt not found in \['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib'\]
NOT AVAILABLE
</code>```

The error message I get is pretty long and I don't know how to interpret it. Here's the rest:

```<code>      atlas_3_10_blas_threads_info:
      Setting PTATLAS=ATLAS
        libraries tatlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_3_10_blas_info:
        libraries satlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_blas_threads_info:
      Setting PTATLAS=ATLAS
        libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_blas_info:
        libraries f77blas,cblas,atlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      accelerate_info:
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1914: UserWarning:
          Optimized (vendor) Blas libraries are not found.
          Falls back to netlib Blas library which has worse performance.
          A better performance should be easily gained by switching
          Blas library.
        if self._calc_info(blas):
      blas_info:
        libraries blas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1914: UserWarning:
          Blas (http://www.netlib.org/blas/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [blas]) or by setting
          the BLAS environment variable.
        if self._calc_info(blas):
      blas_src_info:
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1914: UserWarning:
          Blas (http://www.netlib.org/blas/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [blas_src]) or by setting
          the BLAS_SRC environment variable.
        if self._calc_info(blas):
        NOT AVAILABLE

      non-existing path in 'numpy\\distutils': 'site.cfg'
      lapack_opt_info:
      lapack_mkl_info:
        libraries mkl_rt not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      openblas_lapack_info:
        libraries openblas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      openblas_clapack_info:
        libraries openblas,lapack not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      flame_info:
        libraries flame not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_3_10_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries tatlas,tatlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries tatlas,tatlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries tatlas,tatlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries tatlas,tatlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
        NOT AVAILABLE

      atlas_3_10_info:
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries satlas,satlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries satlas,satlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries satlas,satlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries satlas,satlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_3_10_info'>
        NOT AVAILABLE

      atlas_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries ptf77blas,ptcblas,atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries ptf77blas,ptcblas,atlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries ptf77blas,ptcblas,atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries ptf77blas,ptcblas,atlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_threads_info'>
        NOT AVAILABLE

      atlas_info:
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries f77blas,cblas,atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries f77blas,cblas,atlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries f77blas,cblas,atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries f77blas,cblas,atlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_info'>
        NOT AVAILABLE

      lapack_info:
        libraries lapack not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1748: UserWarning:
          Lapack (http://www.netlib.org/lapack/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [lapack]) or by setting
          the LAPACK environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
      lapack_src_info:
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1748: UserWarning:
          Lapack (http://www.netlib.org/lapack/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [lapack_src]) or by setting
          the LAPACK_SRC environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
        NOT AVAILABLE

      numpy_linalg_lapack_lite:
        FOUND:
          language = c
          define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]

      C:\Users\pytho\AppData\Local\Temp\pip-build-env-r4qjpa7c\overlay\Lib\site-packages\setuptools\_distutils\dist.py:265: UserWarning: Unknown distribution option: 'define_macros'
        warnings.warn(msg)
      running dist_info
      running build_src
      build_src
      building py_modules sources
      creating build
      creating build\src.win-amd64-3.10
      creating build\src.win-amd64-3.10\numpy
      creating build\src.win-amd64-3.10\numpy\distutils
      building library "npymath" sources
      C:\Users\pytho\AppData\Local\Temp\pip-build-env-r4qjpa7c\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py:539: UserWarning: Fallback spawn triggered. Please update distutils monkeypatch.
        warnings.warn("Fallback spawn triggered. Please update distutils monkeypatch.")
      creating build\src.win-amd64-3.10\numpy\core
      creating build\src.win-amd64-3.10\numpy\core\src
      creating build\src.win-amd64-3.10\numpy\core\src\npymath
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npymath\npy_math_internal.h
        adding 'build\src.win-amd64-3.10\numpy\core\src\npymath' to include_dirs.
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npymath\ieee754.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npymath\npy_math_complex.c
      None - nothing done with h_files = ['build\\src.win-amd64-3.10\\numpy\\core\\src\\npymath\\npy_math_internal.h']
      building library "npysort" sources
      creating build\src.win-amd64-3.10\numpy\core\src\common
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\common\npy_sort.h
        adding 'build\src.win-amd64-3.10\numpy\core\src\common' to include_dirs.
      creating build\src.win-amd64-3.10\numpy\core\src\npysort
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\quicksort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\mergesort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\timsort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\heapsort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\radixsort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\common\npy_partition.h
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\selection.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\common\npy_binsearch.h
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\binsearch.c
      None - nothing done with h_files = ['build\\src.win-amd64-3.10\\numpy\\core\\src\\common\\npy_sort.h', 'build\\src.win-amd64-3.10\\numpy\\core\\src\\common\\npy_partition.h', 'build\\src.win-amd64-3.10\\numpy\\core\\src\\common\\npy_binsearch.h']
      building library "npyrandom" sources
      building extension "numpy.core._multiarray_tests" sources
      creating build\src.win-amd64-3.10\numpy\core\src\multiarray
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\multiarray\_multiarray_tests.c
      building extension "numpy.core._multiarray_umath" sources
      BUILD_ARCHITECTURE: 'AMD64', os.name='nt', sys.platform='win32'
      error:
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
</code>```

I tried installing a slightly different version of numpy, but then when I had to install torch it told me there was no compatible version with my previous installations. I already tried using venv instead of conda to create a virtual environment or resetting my computer and installing everything again, but none of that made any difference.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to install the dependencies necessary for a diy teaching library for machine learning engineers (Minitorch), but I get an error after it tries to install a specific version of numpy (1.19.1).

(env) C:\Users\pytho\OneDrive\Documentos\Minitorch\minitorch>python -m pip install -r requirements.txt
Collecting numpy==1.19.1
  Downloading numpy-1.19.1.zip (7.3 MB)
     ---------------------------------------- 7.3/7.3 MB 2.3 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─\> \[242 lines of output\]
Running from numpy source directory.
\<string\>:470: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
C:\\Users\\pytho\\AppData\\Local\\Temp\\pip-install-alzx9eh\_\\numpy_1923ad9693a54691aa73f3e3cd16576b\\tools\\cythonize.py:73: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
required_version = LooseVersion('0.29.21')
C:\\Users\\pytho\\AppData\\Local\\Temp\\pip-install-alzx9eh\_\\numpy_1923ad9693a54691aa73f3e3cd16576b\\tools\\cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(cython_version) \< required_version:
Processing numpy/random_bounded_integers.pxd.in
Processing numpy/random\\bit_generator.pyx
Processing numpy/random\\mtrand.pyx
Processing numpy/random_bounded_integers.pyx.in
Processing numpy/random_common.pyx
Processing numpy/random_generator.pyx
Processing numpy/random_mt19937.pyx
Processing numpy/random_pcg64.pyx
Processing numpy/random_philox.pyx
Processing numpy/random_sfc64.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
No module named 'numpy.distutils.\_msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries mkl_rt not found in \['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib'\]
NOT AVAILABLE

The error message I get is pretty long and I don't know how to interpret it. Here's the rest:

      atlas_3_10_blas_threads_info:
      Setting PTATLAS=ATLAS
        libraries tatlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_3_10_blas_info:
        libraries satlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_blas_threads_info:
      Setting PTATLAS=ATLAS
        libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_blas_info:
        libraries f77blas,cblas,atlas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      accelerate_info:
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1914: UserWarning:
          Optimized (vendor) Blas libraries are not found.
          Falls back to netlib Blas library which has worse performance.
          A better performance should be easily gained by switching
          Blas library.
        if self._calc_info(blas):
      blas_info:
        libraries blas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1914: UserWarning:
          Blas (http://www.netlib.org/blas/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [blas]) or by setting
          the BLAS environment variable.
        if self._calc_info(blas):
      blas_src_info:
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1914: UserWarning:
          Blas (http://www.netlib.org/blas/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [blas_src]) or by setting
          the BLAS_SRC environment variable.
        if self._calc_info(blas):
        NOT AVAILABLE

      non-existing path in 'numpy\\distutils': 'site.cfg'
      lapack_opt_info:
      lapack_mkl_info:
        libraries mkl_rt not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      openblas_lapack_info:
        libraries openblas not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      openblas_clapack_info:
        libraries openblas,lapack not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      flame_info:
        libraries flame not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      atlas_3_10_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries tatlas,tatlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries tatlas,tatlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries tatlas,tatlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries tatlas,tatlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
        NOT AVAILABLE

      atlas_3_10_info:
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries satlas,satlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries satlas,satlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries satlas,satlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries satlas,satlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_3_10_info'>
        NOT AVAILABLE

      atlas_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries ptf77blas,ptcblas,atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries ptf77blas,ptcblas,atlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries ptf77blas,ptcblas,atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries ptf77blas,ptcblas,atlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_threads_info'>
        NOT AVAILABLE

      atlas_info:
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries f77blas,cblas,atlas not found in C:\Users\pytho\.conda\envs\env\lib
        libraries lapack_atlas not found in C:\
        libraries f77blas,cblas,atlas not found in C:\
        libraries lapack_atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries f77blas,cblas,atlas not found in C:\Users\pytho\.conda\envs\env\libs
        libraries lapack_atlas not found in C:\ProgramData\Anaconda3\Library\lib
        libraries f77blas,cblas,atlas not found in C:\ProgramData\Anaconda3\Library\lib
      <class 'numpy.distutils.system_info.atlas_info'>
        NOT AVAILABLE

      lapack_info:
        libraries lapack not found in ['C:\\Users\\pytho\\.conda\\envs\\env\\lib', 'C:\\', 'C:\\Users\\pytho\\.conda\\envs\\env\\libs', 'C:\\ProgramData\\Anaconda3\\Library\\lib']
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1748: UserWarning:
          Lapack (http://www.netlib.org/lapack/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [lapack]) or by setting
          the LAPACK environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
      lapack_src_info:
        NOT AVAILABLE

      C:\Users\pytho\AppData\Local\Temp\pip-install-alzx9eh_\numpy_1923ad9693a54691aa73f3e3cd16576b\numpy\distutils\system_info.py:1748: UserWarning:
          Lapack (http://www.netlib.org/lapack/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [lapack_src]) or by setting
          the LAPACK_SRC environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
        NOT AVAILABLE

      numpy_linalg_lapack_lite:
        FOUND:
          language = c
          define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]

      C:\Users\pytho\AppData\Local\Temp\pip-build-env-r4qjpa7c\overlay\Lib\site-packages\setuptools\_distutils\dist.py:265: UserWarning: Unknown distribution option: 'define_macros'
        warnings.warn(msg)
      running dist_info
      running build_src
      build_src
      building py_modules sources
      creating build
      creating build\src.win-amd64-3.10
      creating build\src.win-amd64-3.10\numpy
      creating build\src.win-amd64-3.10\numpy\distutils
      building library "npymath" sources
      C:\Users\pytho\AppData\Local\Temp\pip-build-env-r4qjpa7c\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py:539: UserWarning: Fallback spawn triggered. Please update distutils monkeypatch.
        warnings.warn("Fallback spawn triggered. Please update distutils monkeypatch.")
      creating build\src.win-amd64-3.10\numpy\core
      creating build\src.win-amd64-3.10\numpy\core\src
      creating build\src.win-amd64-3.10\numpy\core\src\npymath
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npymath\npy_math_internal.h
        adding 'build\src.win-amd64-3.10\numpy\core\src\npymath' to include_dirs.
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npymath\ieee754.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npymath\npy_math_complex.c
      None - nothing done with h_files = ['build\\src.win-amd64-3.10\\numpy\\core\\src\\npymath\\npy_math_internal.h']
      building library "npysort" sources
      creating build\src.win-amd64-3.10\numpy\core\src\common
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\common\npy_sort.h
        adding 'build\src.win-amd64-3.10\numpy\core\src\common' to include_dirs.
      creating build\src.win-amd64-3.10\numpy\core\src\npysort
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\quicksort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\mergesort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\timsort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\heapsort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\radixsort.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\common\npy_partition.h
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\selection.c
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\common\npy_binsearch.h
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\npysort\binsearch.c
      None - nothing done with h_files = ['build\\src.win-amd64-3.10\\numpy\\core\\src\\common\\npy_sort.h', 'build\\src.win-amd64-3.10\\numpy\\core\\src\\common\\npy_partition.h', 'build\\src.win-amd64-3.10\\numpy\\core\\src\\common\\npy_binsearch.h']
      building library "npyrandom" sources
      building extension "numpy.core._multiarray_tests" sources
      creating build\src.win-amd64-3.10\numpy\core\src\multiarray
      conv_template:> build\src.win-amd64-3.10\numpy\core\src\multiarray\_multiarray_tests.c
      building extension "numpy.core._multiarray_umath" sources
      BUILD_ARCHITECTURE: 'AMD64', os.name='nt', sys.platform='win32'
      error:
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I tried installing a slightly different version of numpy, but then when I had to install torch it told me there was no compatible version with my previous installations. I already tried using venv instead of conda to create a virtual environment or resetting my computer and installing everything again, but none of that made any difference.


问:
Same type of dataset, one works, anotherone generates error: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)
```<code>def fast_encode(texts, tokenizer, chunk_size=256, maxlen=128):

    tokenizer.enable_truncation(max_length=maxlen)
    tokenizer.enable_padding()
    all_ids = []

    for i in range(0, len(texts), chunk_size):
        text_chunk = texts[i:i+chunk_size].tolist()
        encs = tokenizer.encode_batch(text_chunk)
        all_ids.extend([enc.ids for enc in encs])
    return np.array(all_ids)
</code>```

The following works perfectly:

```<code>x_train = toxic_df['clean1']
x_dev = dev_df['clean1']
x_test = test_df['clean1']

x_train = fast_encode(x_train.values, fast_tokenizer)
x_dev = fast_encode(x_dev.values, fast_tokenizer)
x_test = fast_encode(x_test.values, fast_tokenizer)

print(type(toxic_df['clean1']))
print(type(toxic_df['clean1'][1]))
print(type(x_train))
print(type(x_train[0]))
print(type(x_train[0][1]))
print(x_train.shape)
</code>```

Corresponding datatype:

```<code>print(type(toxic_df['clean1']))
print(type(toxic_df['clean1'][1]))
print(type(x_train))
print(type(x_train[0]))
print(type(x_train[0][1]))
print(x_train.shape)
</code>```
```<code><class 'pandas.core.series.Series'>
<class 'str'>
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
<class 'numpy.int64'>
(30588, 128)
</code>```

Out put of x_train:

```<code>array([[  101,  1045,  5223, ...,     0,     0,     0],
       [  101,  1036,  1036, ...,     0,     0,     0],
       [  101,  1027,  6775, ...,     0,     0,     0],
       ...,
       [  101,  1036,  1036, ...,  2003,  1996,   102],
       [  101,  2008, 11669, ...,     0,     0,     0],
       [  101,  1037,  5227, ...,     0,     0,     0]])
</code>```

But the next one has the error of : Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)

```<code>x_train1 = train_sentences['line']
x_dev1 = dev_sentences['line']
x_test1 = test_sentences['line']

x_train1 = fast_encode(x_train1.values, fast_tokenizer)
x_dev1 = fast_encode(x_dev1.values, fast_tokenizer)
x_test1 = fast_encode(x_test1.values, fast_tokenizer)
</code>```
```<code>print(type( train_sentences['line']))
print(type( train_sentences['line'][1]))
print(type(x_train1))
print(type(x_train1[0]))
print(type(x_train1[0][1]))
print(x_train1.shape)
</code>```

The corresponding datatypes:

```<code><class 'pandas.core.series.Series'>
<class 'str'>
<class 'numpy.ndarray'>
<class 'list'>
<class 'int'>
(241138,)
</code>```

Out put of x_train1:

```<code>array([list([101, 2187, 2026, 4845, 1999, 1996, 2082, 1998, 4741, 1999, 1996, 5581, 2843, 2000, 12665, 2032, 1024, 1022, 2095, 2214, 4845, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       list([101, 5292, 6687, 3836, 3034, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       list([101, 3188, 1996, 1996, 3034, 2002, 2003, 13847, 2041, 2055, 2242, 1006, 2000, 2026, 2564, 2096, 1045, 2572, 2025, 2045, 1007, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       ...,
       list([101, 1036, 1036, 1027, 1027, 11721, 3319, 1027, 1027, 1024, 2023, 3319, 2003, 9099, 20464, 13936, 2013, 2831, 1024, 2250, 2634, 4671, 3462, 6282, 2475, 1013, 11721, 2487, 1012, 1996, 10086, 4957, 2005, 2023, 2930, 2064, 2022, 2109, 2000, 5587, 7615, 2000, 1996, 3319, 1012, 12027, 1024, 1036, 1036, 1005, 1005, 2029, 2012, 2105, 5757, 1024, 2382, 2334, 2051, 2006, 2570, 2089, 2230, 1010, 1005, 1005, 1005, 1005, 1011, 2017, 2323, 3602, 2029, 2051, 4224, 2009, 2003, 7727, 2000, 2043, 2009, 2360, 1036, 1036, 1005, 1005, 2334, 2051, 1005, 1005, 1005, 1005, 1010, 2030, 2488, 2664, 1010, 2074, 2404, 1996, 2051, 1999, 11396, 1012, 2070, 4431, 2024, 1999, 1996, 3308, 2173, 1010, 2138, 2009, 2298, 2066, 2070, 4861, 2024, 4895, 6499, 3126, 11788, 1012, 2023, 2003, 1996, 102]),
       list([101, 2008, 11669, 2100, 2771, 15714, 19771, 2318, 2000, 7065, 8743, 2026, 2219, 2147, 1998, 2404, 5762, 11669, 2100, 4471, 2006, 2026, 2219, 2686, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       list([101, 1037, 5227, 7592, 4557, 8040, 8747, 7520, 1010, 2115, 7953, 1999, 7367, 22895, 2100, 3720, 11333, 2200, 14044, 1012, 2017, 2156, 2714, 3663, 4158, 1998, 1999, 2023, 3720, 1010, 2007, 1996, 2168, 3218, 1997, 18558, 28649, 8208, 1012, 4385, 1012, 2071, 2017, 3531, 2156, 1996, 6594, 2182, 1998, 3073, 2115, 7615, 2006, 2023, 3277, 1029, 1045, 2052, 2022, 2200, 8794, 2000, 2017, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])],
      dtype=object)
</code>```

It is obvious they are different, and I have been trying to solve it for a long while, I tried most of the solution that is listed online already, but none of them work, I am not sure if I miss anything, so any suggestion is appreciated. Thank you!

What can I do to make the result of x_train1 have the same format/datatype as x_train? Thank you!!

Body:
def fast_encode(texts, tokenizer, chunk_size=256, maxlen=128):

    tokenizer.enable_truncation(max_length=maxlen)
    tokenizer.enable_padding()
    all_ids = []

    for i in range(0, len(texts), chunk_size):
        text_chunk = texts[i:i+chunk_size].tolist()
        encs = tokenizer.encode_batch(text_chunk)
        all_ids.extend([enc.ids for enc in encs])
    return np.array(all_ids)

The following works perfectly:

x_train = toxic_df['clean1']
x_dev = dev_df['clean1']
x_test = test_df['clean1']

x_train = fast_encode(x_train.values, fast_tokenizer)
x_dev = fast_encode(x_dev.values, fast_tokenizer)
x_test = fast_encode(x_test.values, fast_tokenizer)

print(type(toxic_df['clean1']))
print(type(toxic_df['clean1'][1]))
print(type(x_train))
print(type(x_train[0]))
print(type(x_train[0][1]))
print(x_train.shape)

Corresponding datatype:

print(type(toxic_df['clean1']))
print(type(toxic_df['clean1'][1]))
print(type(x_train))
print(type(x_train[0]))
print(type(x_train[0][1]))
print(x_train.shape)

<class 'pandas.core.series.Series'>
<class 'str'>
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
<class 'numpy.int64'>
(30588, 128)

Out put of x_train:

array([[  101,  1045,  5223, ...,     0,     0,     0],
       [  101,  1036,  1036, ...,     0,     0,     0],
       [  101,  1027,  6775, ...,     0,     0,     0],
       ...,
       [  101,  1036,  1036, ...,  2003,  1996,   102],
       [  101,  2008, 11669, ...,     0,     0,     0],
       [  101,  1037,  5227, ...,     0,     0,     0]])

But the next one has the error of : Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)

x_train1 = train_sentences['line']
x_dev1 = dev_sentences['line']
x_test1 = test_sentences['line']

x_train1 = fast_encode(x_train1.values, fast_tokenizer)
x_dev1 = fast_encode(x_dev1.values, fast_tokenizer)
x_test1 = fast_encode(x_test1.values, fast_tokenizer)

print(type( train_sentences['line']))
print(type( train_sentences['line'][1]))
print(type(x_train1))
print(type(x_train1[0]))
print(type(x_train1[0][1]))
print(x_train1.shape)

The corresponding datatypes:

<class 'pandas.core.series.Series'>
<class 'str'>
<class 'numpy.ndarray'>
<class 'list'>
<class 'int'>
(241138,)

Out put of x_train1:

array([list([101, 2187, 2026, 4845, 1999, 1996, 2082, 1998, 4741, 1999, 1996, 5581, 2843, 2000, 12665, 2032, 1024, 1022, 2095, 2214, 4845, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       list([101, 5292, 6687, 3836, 3034, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       list([101, 3188, 1996, 1996, 3034, 2002, 2003, 13847, 2041, 2055, 2242, 1006, 2000, 2026, 2564, 2096, 1045, 2572, 2025, 2045, 1007, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       ...,
       list([101, 1036, 1036, 1027, 1027, 11721, 3319, 1027, 1027, 1024, 2023, 3319, 2003, 9099, 20464, 13936, 2013, 2831, 1024, 2250, 2634, 4671, 3462, 6282, 2475, 1013, 11721, 2487, 1012, 1996, 10086, 4957, 2005, 2023, 2930, 2064, 2022, 2109, 2000, 5587, 7615, 2000, 1996, 3319, 1012, 12027, 1024, 1036, 1036, 1005, 1005, 2029, 2012, 2105, 5757, 1024, 2382, 2334, 2051, 2006, 2570, 2089, 2230, 1010, 1005, 1005, 1005, 1005, 1011, 2017, 2323, 3602, 2029, 2051, 4224, 2009, 2003, 7727, 2000, 2043, 2009, 2360, 1036, 1036, 1005, 1005, 2334, 2051, 1005, 1005, 1005, 1005, 1010, 2030, 2488, 2664, 1010, 2074, 2404, 1996, 2051, 1999, 11396, 1012, 2070, 4431, 2024, 1999, 1996, 3308, 2173, 1010, 2138, 2009, 2298, 2066, 2070, 4861, 2024, 4895, 6499, 3126, 11788, 1012, 2023, 2003, 1996, 102]),
       list([101, 2008, 11669, 2100, 2771, 15714, 19771, 2318, 2000, 7065, 8743, 2026, 2219, 2147, 1998, 2404, 5762, 11669, 2100, 4471, 2006, 2026, 2219, 2686, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
       list([101, 1037, 5227, 7592, 4557, 8040, 8747, 7520, 1010, 2115, 7953, 1999, 7367, 22895, 2100, 3720, 11333, 2200, 14044, 1012, 2017, 2156, 2714, 3663, 4158, 1998, 1999, 2023, 3720, 1010, 2007, 1996, 2168, 3218, 1997, 18558, 28649, 8208, 1012, 4385, 1012, 2071, 2017, 3531, 2156, 1996, 6594, 2182, 1998, 3073, 2115, 7615, 2006, 2023, 3277, 1029, 1045, 2052, 2022, 2200, 8794, 2000, 2017, 1012, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])],
      dtype=object)

It is obvious they are different, and I have been trying to solve it for a long while, I tried most of the solution that is listed online already, but none of them work, I am not sure if I miss anything, so any suggestion is appreciated. Thank you!

What can I do to make the result of x_train1 have the same format/datatype as x_train? Thank you!!


问:
What is the S3 hostedZoneId input used for?
Digging through our Pulumi code, I see that it sets the hostedZoneId on the S3 bucket it creates and I don't understand what it's used for.

The bucket holds internal content (Pulumi state files) and is not set as a static website.

The Pulumi docs in AWS S3 Bucket hostedZoneId only state:

The Route 53 Hosted Zone ID for this bucket's region.

with a link to what appears to be an irrelevant page (looks like a copy-paste error since that link is mentioned earlier on the page).

S3 API docs don't mention the field either.

Terraform's S3 bucket docs, which Pulumi relies on many times but is also a good reference for S3 API in general, exposes this as an output, but not as an input attribute.

Does anyone know what this attribute is used for?


问:
Sharing Rich Links in Swift
I am trying to implement rich link sharing on posts within my app. Sharing a link in iMessage should show the video or image if there's one associated with the post. This swift implementation is not working, not sure if its my code or and issue with the website meta data

What do I need in my website to make this work? Is the current swift implementation

```<code>  static func addURLPreview(urlString: String) {
        let metaDataProvider = LPMetadataProvider()
        let url = URL(string: urlString)
        metaDataProvider.startFetchingMetadata(for: url!) { (metaData, error) in
            guard let _ = error, let metaData = metaData else {
                return
            }

            let vc = UIActivityViewController(activityItems: [metaData], applicationActivities: nil)
            UIApplication.shared.getKeyWindow()?.rootViewController?.present(vc, animated: true)
        }
    }
</code>```

Title: Sharing Rich Links in Swift

Body:
I am trying to implement rich link sharing on posts within my app. Sharing a link in iMessage should show the video or image if there's one associated with the post. This swift implementation is not working, not sure if its my code or and issue with the website meta data

What do I need in my website to make this work? Is the current swift implementation

  static func addURLPreview(urlString: String) {
        let metaDataProvider = LPMetadataProvider()
        let url = URL(string: urlString)
        metaDataProvider.startFetchingMetadata(for: url!) { (metaData, error) in
            guard let _ = error, let metaData = metaData else {
                return
            }

            let vc = UIActivityViewController(activityItems: [metaData], applicationActivities: nil)
            UIApplication.shared.getKeyWindow()?.rootViewController?.present(vc, animated: true)
        }
    }


问:
Keep reviving a null value after calling a future function, but the data is clearly there
I am trying to use a geolocator and then put the values from the data received from a plug in into a list so I can then sort it. The problem is that when I try to add said data to the list, I get an error saying that the value being added is null, and then another one saying that I tried to call add(whatever number I tried to add to the list was) I know that it is because future variables and regular variables are treated differently. Does anyone know how to convert a future variable to a normal one? The async function and main code are as follows

***The following code is my main code, it creates a list of widgets, I am trying to organize them so that the smallest value is first- however I am organizing them by distance, and I cannot get the distance without a future function

```<code> return ListView(
            //This part works just grabs my firebase documents
            children: snapshot.data.docs.map((document) {
              //index++;
             GeoPoint tempVar = document['location'];
//This part does not work
                List<int> widgetIds;
          Future<double> listValue = getDistance(tempVar);
       listValue.then((double future) {
          if(listValue != null){

           var newV = myList(listValue.round());
           print('$newV');
          }
          if(listValue == null){}

             });
              //trashcans[index].description = document['description'];
              // List<double> widgetIds = newVar;
              // print(widgetIds);
//this part works, puts them in into a custom widget
              return canTemplate(document, context,);

              // return Container(
              //   child: Center(child: Text(document['description'] + " - " + document['full']),),
            }).toList(),
          );
</code>```

Here is my getDistance() function, it works with the normal template that I had, but now that I am trying to save the values in variables it does not work

```<code>

Future <double> getDistance(GeoPoint loc) async {
  Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  double lat1 = position.latitude;
  double long1 = position.longitude;
  double lat2 = loc.latitude;
  double long2 = loc.longitude;
  double distanceInMeters = await Geolocator().distanceBetween(lat1, long1, lat2, long2);
  double feet = distanceInMeters * 3.28084;

  return feet;
}
</code>```

Here is the myList function, I thought that if I could create the list as a future variable it would solve the issue but it doesnt work

```<code>Future <List> myList(int data) async{
  List widgetIds;
  widgetIds.add(data);
  return widgetIds;
}
</code>```

These are the errors I get
/flutter ( 5177): Closure: (int) => Future<List> from Function 'myList': static.
E/flutter ( 5177): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: The method 'add' was called on null.
E/flutter ( 5177): Receiver: null
E/flutter ( 5177): Tried calling: add(1046046)

As you can see it has the number I want, but for some reason the value is still considered null

for some reason when I use the await call, for examples instead of doing

```<code>var newV = myList(listValue.round());
</code>```

I change it to this

```<code>var newV = await myList(listValue.round());
</code>```

It states that await can only be used on a future and not a double

Body:
I am trying to use a geolocator and then put the values from the data received from a plug in into a list so I can then sort it. The problem is that when I try to add said data to the list, I get an error saying that the value being added is null, and then another one saying that I tried to call add(whatever number I tried to add to the list was) I know that it is because future variables and regular variables are treated differently. Does anyone know how to convert a future variable to a normal one? The async function and main code are as follows

***The following code is my main code, it creates a list of widgets, I am trying to organize them so that the smallest value is first- however I am organizing them by distance, and I cannot get the distance without a future function

 return ListView(
            //This part works just grabs my firebase documents
            children: snapshot.data.docs.map((document) {
              //index++;
             GeoPoint tempVar = document['location'];
//This part does not work
                List<int> widgetIds;
          Future<double> listValue = getDistance(tempVar);
       listValue.then((double future) {
          if(listValue != null){

           var newV = myList(listValue.round());
           print('$newV');
          }
          if(listValue == null){}

             });
              //trashcans[index].description = document['description'];
              // List<double> widgetIds = newVar;
              // print(widgetIds);
//this part works, puts them in into a custom widget
              return canTemplate(document, context,);

              // return Container(
              //   child: Center(child: Text(document['description'] + " - " + document['full']),),
            }).toList(),
          );

Here is my getDistance() function, it works with the normal template that I had, but now that I am trying to save the values in variables it does not work

Future <double> getDistance(GeoPoint loc) async {
  Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  double lat1 = position.latitude;
  double long1 = position.longitude;
  double lat2 = loc.latitude;
  double long2 = loc.longitude;
  double distanceInMeters = await Geolocator().distanceBetween(lat1, long1, lat2, long2);
  double feet = distanceInMeters * 3.28084;

  return feet;
}

Here is the myList function, I thought that if I could create the list as a future variable it would solve the issue but it doesnt work

Future <List> myList(int data) async{
  List widgetIds;
  widgetIds.add(data);
  return widgetIds;
}

These are the errors I get
/flutter ( 5177): Closure: (int) => Future<List> from Function 'myList': static.
E/flutter ( 5177): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: The method 'add' was called on null.
E/flutter ( 5177): Receiver: null
E/flutter ( 5177): Tried calling: add(1046046)

As you can see it has the number I want, but for some reason the value is still considered null

for some reason when I use the await call, for examples instead of doing

var newV = myList(listValue.round());

I change it to this

var newV = await myList(listValue.round());

It states that await can only be used on a future and not a double


问:
I got this Error when i try to install reNgine, any Suggest?
when I try to install reNgine recon tool, it always stops at (32/51) and gives me this error, I tried searching for it but no luck

failed to solve: executor failed running [/bin/sh -c GO111MODULE=on go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest]: exit code: 2
make: *** [Makefile:22: up] Error 17

I tried to run

GO111MODULE=on go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest

and reinstall it but the same Error pops up


问:
Is there a way to stop ffmpeg from combining mp4s at max mp4 size?
I am merging 64 gigs of mp4s together, though ffmpeg will go past the file size limit and corrupt it. Is there a way to stop ffmpeg at a 100 hour mark and create another file, resume, then repeat until finished?

This is my python code, with the ffmpeg code I used to generate the mp4. It works fine with less files/

from moviepy.editor import *
import os
from natsort import natsorted

L = []
total = 0
for root, dirs, files in os.walk("F:\door"):
    #files.sort()
    files = natsorted(files)
    with open("list.txt", "a") as filer:
            for file in files:
                if os.path.splitext(file)[1] == '.mp4':
                    filePath = os.path.join(root, file)
                    head, tail = os.path.split(filePath)
                    filePath = "file '" + str(tail)+"'\n"
                    print(filePath)
                    filer.write(filePath)

                    #run in cmd: ffmpeg -f concat -i list.txt -c copy output.mp4

```


问:
I don't understand why when I run the file a second time and press N the if loop doesn't respond correctly but when I press Y it does
```<code>import json

filename = "user_names.json"

def greet_user():
    print("Welcome to My program that asks and then remembers your name.")

    try:
        name = stored_user()

    except FileNotFoundError:
        new_user()

    query = input(f"We have detected a possible previous user. Is your name {name}? Enter Y or N to proceed.\n")
    answer = query.upper()

    if answer != "Y" and "N":
        error()

    elif answer == "N":
        new_user()

    elif answer == "Y":
        name = stored_user()
        print(f"Welcome back, {name}.")
        goodbye()

def stored_user():
    with open(filename) as f:
        name = json.load(f)
        return name

def new_user():
    name = input("Please enter your name. I will remember it next time you come back on the site. \n")
    with open(filename, "w") as f:

        json.dump(name, f)
        goodbye()

def goodbye():
    print("Thank you for using my program.")

def error():
    print("Only 'Y' and 'N' responses are considered valid.\nPlease try again")
    greet_user()

greet_user()
</code>```

When I run the program a first time everything goes correctly. Asks for the users name then stores it in a newly created json file. However when you run the file a second time and choose to not be the previous user by pressing N in the if loop it does not go into the new_user() function but instead the error function. Oddly when I press Y it correctly will go into the welcome back prompt and goodbye function. Any reasons why?

Body:
import json

filename = "user_names.json"

def greet_user():
    print("Welcome to My program that asks and then remembers your name.")

    try:
        name = stored_user()

    except FileNotFoundError:
        new_user()

    query = input(f"We have detected a possible previous user. Is your name {name}? Enter Y or N to proceed.\n")
    answer = query.upper()

    if answer != "Y" and "N":
        error()

    elif answer == "N":
        new_user()

    elif answer == "Y":
        name = stored_user()
        print(f"Welcome back, {name}.")
        goodbye()

def stored_user():
    with open(filename) as f:
        name = json.load(f)
        return name

def new_user():
    name = input("Please enter your name. I will remember it next time you come back on the site. \n")
    with open(filename, "w") as f:

        json.dump(name, f)
        goodbye()

def goodbye():
    print("Thank you for using my program.")

def error():
    print("Only 'Y' and 'N' responses are considered valid.\nPlease try again")
    greet_user()

greet_user()

When I run the program a first time everything goes correctly. Asks for the users name then stores it in a newly created json file. However when you run the file a second time and choose to not be the previous user by pressing N in the if loop it does not go into the new_user() function but instead the error function. Oddly when I press Y it correctly will go into the welcome back prompt and goodbye function. Any reasons why?


问:
how to make spring mongo code using GroupOperation and MatchOpertation
i'd like to make code using GroupOperation and another MatchOpertation

```<code>[
  {
    $match: {
      status: "APPROVED",
    },
  },
  {
    $group: {
      _id: "$userId",
      count: {
        $count: {},
      },
    },
  },
  {
    $match: {
      count: {
        $gte: 2,
      },
    },
  },
</code>```

i want to make code like the upper side

this is what i tried. but when i see the query, $sum automatically following because of the count function. what is the best way to change it?

Body:
i'd like to make code using GroupOperation and another MatchOpertation

[
  {
    $match: {
      status: "APPROVED",
    },
  },
  {
    $group: {
      _id: "$userId",
      count: {
        $count: {},
      },
    },
  },
  {
    $match: {
      count: {
        $gte: 2,
      },
    },
  },

i want to make code like the upper side

this is what i tried. but when i see the query, $sum automatically following because of the count function. what is the best way to change it?


问:
Apply margins to a scaled canvas
Im fixing a html game my friend send me and the game is locked to 1080px so I wrote a JS script that uses transform: scale(n, n); that scales the canvas to fit the screen. However when it does that the top part of the canvas is displayed offscreen and i can't figure out how to apply margins automaticly to make it stay on screen

```<code>function percentage(partialValue, totalValue) {
    return (100 * partialValue) / totalValue;
 }
var widprtp = percentage(self.innerWidth, 1048);
var higprtp = percentage(self.innerHeight, 772);
var render = document.getElementById("canvas")
render.style.transform = `scale(${widprtp}%,${higprtp}%)`
</code>```

Im still new to StacksOverflow so let me know if you need more information
Sorry I gave the varibles weird names lol

Title: Apply margins to a scaled canvas

Body:
Im fixing a html game my friend send me and the game is locked to 1080px so I wrote a JS script that uses transform: scale(n, n); that scales the canvas to fit the screen. However when it does that the top part of the canvas is displayed offscreen and i can't figure out how to apply margins automaticly to make it stay on screen

function percentage(partialValue, totalValue) {
    return (100 * partialValue) / totalValue;
 }
var widprtp = percentage(self.innerWidth, 1048);
var higprtp = percentage(self.innerHeight, 772);
var render = document.getElementById("canvas")
render.style.transform = `scale(${widprtp}%,${higprtp}%)`

Im still new to StacksOverflow so let me know if you need more information
Sorry I gave the varibles weird names lol