indexerror tuple index out of range

Хочу узнать размер изображения, решение следующее, с помощью pgmagick открываю изображения и сохраняю его в массив:

и с помощью numpy узнать размер

В результате вижу такую ошибку:

Traceback (most recent call last): File
«/home/alex/PycharmProjects/untitled/create_file_annotation.py», line
56, in
w > 2702, in size
return asarray(a).shape[axis] IndexError: tuple index out of range

А самое интересное, что я поставил print weight,height и перед ошибкой размер изображения выдается правильный, в чем может быть причина ошибки? Python использую версии 2.7

Comments

Copy link Quote reply

richard-bibb commented Apr 2, 2017

Code Sample, a copy-pastable example if possible

Problem description

The above code works in an old version of pandas (0.7.3) but fails in the current version (0.19.2)

Expected Output

No error and dataframe containing the numpy date array

Output of pd.show_versions()

pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 20.10.1
Cython: None
numpy: 1.12.1
scipy: None
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None

This comment has been minimized.

Copy link Quote reply

chrisaycock commented Apr 4, 2017

Interestingly, this works:

But this does not:

Numpy doesn’t seem to handle the input arrays any differently, but create_block_manager_from_blocks() definitely shows different blocks . The first is

while the second is

I’m going to dig some more into this.

This comment has been minimized.

Copy link Quote reply

jreback commented Apr 4, 2017 •

When we have a 1-d array that is object we want to see whether its datetimelike or not. So I did this old thing where I would sample the first 3 elements. This is bogus now as can simply do this (also need to tests for timedelta as well).

It might be better to simply modify is_possible_datetimelike_array as an alternative (it is called below as well).

These routines are robust to null values, check for the requested (datetime or timedelta-like), and don’t read the entire routine if is just strings (which is the point here, we are trying to see w/o doing too much work if we can coerce this). This is called for every object array on construction, so this needs to be cheap.

This may seem like overly paranoid / extreme. But remember we can actually have mixed dtypes that get coerced, e.g.:

but we need it be robust to non-matching types.

RedEye

New Member

Using Linux Mint 19 Cinnamon. Really hoping I can get a hand with this as its my livelihood and I live in the middle of nowhere! Please be gentle with me because even though I’m a long time user, I’m still not the best with this stuff but I can follow directions! I will be glued to this forum so any info you need, ill obtain it right away!

So I’m currently trying to get clockworkmod onto linux. It worked before but recently installed a fresh OS using the same file from last time. I found another forum that had the same problem which worked for him but its not working for me. So here is my problem.

/1/1$ dir
common linux node node-tuntap README
[email protected]:

/1/1/node$ dir
AUTHORS common.gypi deps make-darwin.sh src
benchmark config.gypi doc Makefile test
BSDmakefile config.mk lib node.gyp tools
ChangeLog configure LICENSE README.md vcbuild.bat
[email protected]:

/1/1/node$ ./configure
Traceback (most recent call last):
File «./configure», line 463, in
configure_node(output)
File «./configure», line 370, in configure_node
o[‘variables’][‘gcc_version’] = 10 * cc_version[0] + cc_version[1]
IndexError: tuple index out of range

The solution on other forum was to enter
proc = subprocess.Popen(CC.split() + [‘-dumpversion’], stdout=subprocess.PIPE)

Then change dumpversion to dumpfullversion

When I enter that proc code i get this
bash: syntax error near unexpected token `(‘

Condobloke

Well-Known Member

G’day RedEye, and Welcome to linux.org

I dont know the answer. but someone will . i am putting in this post to hopefully help your topic to ‘stay put». I have no clue why it was deleted. most unusual. perhaps @wizardfromoz may be able to shed some light ?

Anyway. good luck. I will watch with interest

Condobloke . Outback Australian :: fed up with Windows antics. . LINUX IS THE ANSWER. I USE LINUX MINT 18.3 EXCLUSIVELY.

“A man travels the world in search of what he needs and returns home to find it.«

It has been said that time heals all wounds. I don’t agree. The wounds remain. Time — the mind, protecting its sanity — covers them with some scar tissue and the pain lessens, but it is never gone. Rose Kennedy

RedEye

New Member

I had another thought of what was causing this. Again just shooting in the dark but maybe it was libssl-dev? I typed sudo apt-get install libssl-dev and that was all. Not sure if there is an extra step to get it fully installed and maybe thats whats causing my problem? If not, just ignore this bit lol

Condobloke

Well-Known Member
  1. Update the package index: # sudo apt-get update
  • Install libssl-dev deb package:
    # sudo apt-get install libssl-dev
  • from : HERE

    Condobloke . Outback Australian :: fed up with Windows antics. . LINUX IS THE ANSWER. I USE LINUX MINT 18.3 EXCLUSIVELY.

    “A man travels the world in search of what he needs and returns home to find it.«

    It has been said that time heals all wounds. I don’t agree. The wounds remain. Time — the mind, protecting its sanity — covers them with some scar tissue and the pain lessens, but it is never gone. Rose Kennedy

    RedEye

    New Member

    wizardfromoz

    Super Moderator

    My ears are burning — who invoked the name of the Wizard?

    (Wizard appears in a puff of smoke)

    G’day Redeye from another Aussie, and welcome

    Not deleted, set aside for Approval . occasionally a Post will trigger our site software into holding a Thread, usually to do with a URL (website address) being mentioned inside a quote or reply box.

    Such was not the case here, so I am at a loss to account for it, regrets.

    Your Original Post came across my (virtual) desk for approval when I came online a little while ago. Seeing nothing wrong with it, I approved it straight away.

    It is restored, but it is in Networking, where you first placed it.

    Given Brian (@Condobloke ) has responded to you, I am inclined to move from the other Thread to this one, relevant material that is not duplicated and then close off the other one, but then move THIS one to Networking.

    Anybody remain un-confused?

    Mate you said in the other

    Do be aware that despite our site name, we are not an official arm nor organ of LInux — just jagged the domain name early in the piece.

    We are staffed and manned by happy volunteers who enjoy their Linux, and have varying levels of skills and knowledge in many areas. Also timezones are from around the world, so response times can be a little frustrating

    Hope we can help

    Chris Turner
    wizardfromoz

    JasKinasis

    Well-Known Member

    =
    The solution on other forum was to enter
    proc = subprocess.Popen(CC.split() + [‘-dumpversion’], stdout=subprocess.PIPE)

    Then change dumpversion to dumpfullversion

    When I enter that proc code i get this
    bash: syntax error near unexpected token `(‘

    Clockworkmod USB tethering with Ubuntu 18.04

    Then the instruction is to find the existing line of the script where the variable proc is assigned a value and change -dumpversion to -dumpfullversion.

    If you did exactly that, you shouldn’t be getting an error message, so unless I’m mistaken — it sounds like you’ve copy pasted that line of code somewhere inappropriate and have changed -dumpversion to -dumpfullversion.

    Looking at the line of code itself — it looks like it’s a python script — not a shell-script. It might be a snippet of python script that has been embedded inside the shellscript. So again, if you copy/pasted that line of code into a part of the script that is meant to be shellscript — that might explain the problem you are having.

    Restore the makefile back to it’s original state — then track-down the line of code where proc is assigned a value using subprocess.Popen and make the change that was in the instructions and see how you get on.

    And again — I could be mistaken with my diagnosis — so apologies if I am incorrect, but I think this is what’s going on!

    JasKinasis

    Well-Known Member

    UPDATE:
    I’ve just downloaded the linux package for clockworkmod and taken a look at the installer.

    The configure script is a python script — so I don’t understand why you’re getting an error from bash.
    Did you just copy/paste that line of code into a terminal??

    I can verify that if you open the configure script and go to line 325, change the word -dumpversion to -dumpfullversion — the configuration script will run properly without any errors!

    RedEye

    New Member

    RedEye

    New Member

    Woohoo! made it through the configure part. For anyone who needs what was said above put in layman’s terms, go to your clockworkmod folder then node folder. Click on the blue and yellow logo labeled «configure» and press ctrl F to word search. Enter dump and you will see what you need to change it to dumpfullversion. You can now do the ./configure.

    but now I’m getting this. Also how do u guys put these logs into a smaller format? ill edit and do so if i can figure it out.

    Оцените статью