Can't get the correct version of GDAL installed to use ReadAsArray without getting error in Python

Can't get the correct version of GDAL installed to use ReadAsArray without getting error in Python

Using the instructions here… I downloaded the following files: and gdal-111-1800-x64-core.msi

After doing this I was able to create my Python script (which manipulates DTED data), and run this script from my C# code.

Then I ran into a few problems when attempting to manipulate the pixel values of the DTED file: 1) I'm trying to use ReadAsArray and I get "ImportError: No module named _gdal_array" on the line in my Python script… data = rb.ReadAsArray(0, 0, cols, rows) Referred to: Cannot import gdal_array 2) I also thought that I could use gdallocationinfo… I get a syntax error on the file name…

gdallocationinfo C:DataTestFilesTST.DT1 1000 1000 SyntaxError: invalid syntax

I find that it gives an error message on any file name that I enter.

Therefore, I installed OSGeo4W in order to be able to use some of the above mentioned GDAL functions that I would need (after reading this By running the OSGeo4W Shell, I was able to type this in at the command line and get the desired result:

C:>gdallocationinfo C:DataTestFilesTST.DT1 1000 1000 Report: Location: (1000P,1000L) Band 1: Value: 859

The problem is that I don't think that I can use a Python script with this OSGeo4W shell, which means that I would have to run some other kind of script from my C# code, I guess.

Are there other versions of msi files that I should have downloaded instead of and gdal-111-1800-x64-core.msi?

I'm just not sure which approach I should take.

I was able to get around this problem by using ReadRaster:

from osgeo import gdal,ogr ds = gdal.Open( 'C:/Data/TestFiles/DtedFile.DT1' ) rb=ds.GetRasterBand(1) import struct xsize = rb.XSize ysize = rb.YSize datatype = rb.DataType #Reading the raster values values = rb.ReadRaster( 0, 0, xsize, ysize, xsize, ysize, datatype ) #Conversion between GDAL types and python pack types data_types ={'Byte':'B','UInt16':'H','Int16':'h','UInt32':'I','Int32':'i','Float32':'f','Float64':'d'} values = struct.unpack(data_types[gdal.GetDataTypeName(rb.DataType)]*xsize*ysize,values) #Now you can view any of these values in the array. print(values[35])

APT is a package management system for Debian and other Linux distributions based on it, such as Ubuntu. For the most part, APT is easy to use for installing, removing, and updating packages. In rare instances, often when you are mixing in third-party dependencies, there is a chance that apt-get may end up giving you an error telling you that a package installation could not be completed.

It is always a good idea to back up configuration files like /etc/apt/sources.list , so you can revert the changes if needed.

If the error shows something like this:

<some-package>: Depends: <other-package> (= version) but this-version is to be installed

Then make sure that the restricted and universe repositories are enabled. Hit Alt + F2 , type software-properties-gtk and hit Enter .

Under Ubuntu Software tab, enable all the repositories.

One possible cause of unmet dependencies could be corrupted package database, and/or some packages weren’t installed properly. To fix this problem, hit Alt + Ctrl + T to open terminal and try to run one of the following commands:

apt-get clean clears out the local repository of retrieved package files (the .deb files). It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. apt-get autoclean clears out the local repository of retrieved package files, but unlike apt-get clean , it only removes package files that can no longer be downloaded, and are largely useless.

One of the most basic fixes to resolve dependencies problems is to run:

The -f here stands for “fix broken”. Apt will attempt to correct broken dependencies. If you manually installed a package that had unmet dependencies, apt-get will install those dependencies, if possible, otherwise it may simply remove the package that you installed in order to resolve the problem.

0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

If it shows any held packages, it is best to eliminate them. Packages are held because of dependency conflicts that apt cannot resolve. Try this command to find and repair the conflicts:

If it cannot fix the conflicts, it will exit with:

0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

Delete the held packages one by one, running dist-upgrade each time, until there are no more held packages. Then reinstall any needed packages. Be sure to use the --dry-run option, so that you are fully informed of consequences:

Since removing the package you are trying to install may not be ideal, you might also try finding a repository that has the packages you need to satisfy the dependencies.

Finally, if all else fails, you can attempt to satisfy the dependencies yourself, either by finding and installing the necessary packages, or by installing them from source and then creating “deb” packages for them.

(This method requires updating symlinks when versions change. i.e. not ideal)

For those who use homebrew, it is probably better to just use a symlink, otherwise all kinds of havoc could emerge. e.g. the official python binary will modify your

./bash_profile so that python3 and pip3 no longer point to brew.

In my case I've now symlinked the homebrew version (along the lines of the discussion in the answer provided by @Evenfire):

QGIS3 then complained that certain python packages were missing, which can be installed with pip3, e.g.

It might also complain about gdal , in my case I simply used brew:

2 Answers 2

Your schematic is as follows:

Above, you can see that $R_2$ and $Z_2$ form a voltage divider that divides $V_Y$ into $V_ ext$ . It follows that:

Let's do this in sympy:

Then I just built this schematic:

So what's the problem?? I think you need to look more closely either at your algebra process or else for typos in your laplace function. I used a direct "copy/paste" operation directly from sympy to LTspice, to minimize the chances for error.

When I see the amount of lines thrown on the blank page by the OP as an attempt to derive this 3rd-order transfer function, I think it is about time time that fast analytical circuits techniques or FACTs are taught in universities. The principle is simple and, very often, works with inspection: just look at the circuit to infer the time constants without writing a single line of algebra. The exercise consists of determining the resistance $R$ offered by each energy-storing element when the circuit is observed with a zeroed excitation or with a nulled response. Once you have the $R$ , you can form a time constant expressed as $ au=RC$ or $ au=frac$ .

So we start with a bunch of small sketches to determine the natural time constants of this linear circuit. We reduce the excitation to zero volt (the input source is replaced by a short circuit) and you "look" through the energy-storing element temporarily disconnected from the circuit to find the resistance $R$ driving that element:

As you can see, you just inspect the drawing to see, in your head, what resistance the terminals in question offer (where the arrow points). And if you make a mistake, it is easy and fast to come back to the circuit and correct the resistance $R$ you mistakenly determined.

For the zeroes, you can do what is a called a null double injection (NDI) but I often prefer for the passive case, to determine high-frequency gains: the source is back in place and you inspect the circuit to determine what the gains are when energy-storing elements are alternately placed in their high-frequency state:

You can see how easy it is! When you have all these elements on hand, you assemble them in a Mathcad sheet which a) will check homogeneity of the formulas and b) will let you compare the response obtained by the FACTs and that delivered by the brute-force approach (Thévenin in this case):

Then you can plot the magnitude and phase while comparing the two responses in similar plots. They perfectly match as shown below:

You can see how easy the FACTs are compared to the classical KVL and KCL methods. You apply the divide-and-conquer strategy promoted by Dr. Middlebrook and solve your circuit step-by-step with the ability to come back and solve an intermediate wrong result. There is no way you can do that with the brute-force approach.

Acquiring the FACTs skill is simple and you can start with 1st-order circuits as shown in the APEC seminar I taught in 2016. Then, for an in-depth description of the method up to the order $N$ , you can have a look at the book I published on the subject.

6 Answers 6

Edit: While the app now launches, it still won't let me scan. Found this saying that the certificate from HP has been revoked, and we're SOL until HP fixes it.

I had this same issue this morning, did a search and found this. Apparently there is a version it the App Store. I downloaded that and boom it's working. Guess they want you to use the one that's been "vetted".

This message happens when the certificate used to sign software gets revoked. The OS does check for revocations online so yes it blocks apps even if you don’t update the apps or the OS.

For HP printers and scanners, the problem is the revocation of the certificates HP used to sign their software, not that macOS checks for revoked certificates. Things are working technically how they should, but from a support and culture perspective, I am certain thousands (perhaps millions) of people are realizing “suddenly” that this is built into their OS.

The vast majority of HP apps for macOS (which are slightly different than the driver stubs needed for printing) were signed by now revoked certificates.

You are correct in scanning software will not work unless you ignore revoked signed apps or update your software. Here is the package we pushed to thousands of Macs around noon yesterday to address yesterday’s specific certificate revocation.

Run software updates and you should see updates for HP or worst case see if you can get support from them (they will be very busy the next few days while this all sorts out)

If you want to check your software, here are two apps I love and use to check certificates and signing status.

I tried to update the driver from HP, but that did not help much.

After uninstallation was completed, I installed the latest HP driver again and that message is gone. Now I can print and scan with no issues anymore.

HP Easy Start instructions: Please update your software using HP Easy Start.

  1. Download HP Easy Start
  2. Follow the prompts for setting up your printer. When you get to the software download it will show whether the software needs updated or not. If it does the box next to Printer Essentials will be checked by default and you just need to select the Install button.

TLDR Reinstall the printer using the "Generic PCL laser printer" (even if it's an inkjet!).

I had this problem with my HP Officejet H470 after upgrading to Big Sur (warning it would damage my computer)

I uninstalled it but couldn't install the HP software because it gave me this warning:

I then removed the printer and re-added it using the "Generic PCL laser printer" (even though it's an inkjet!). Yay :

No, sorry. That particular message does not indicate macOS has decided to block anything. That wording is so clearly wrong, it indicates someone is trying to scam you. Prolly, the scam will involve an instruction/suggestion to replace the "suspect" software.

I've been providing tech support to both Apple and HP users since before there were Macs, let alone macOS, and I've never seen or heard of that wording.

The meaning is exactly as speculated but the wording did not come from either Apple or HP

If you have support contracts call Apple and HP and ask them to ignore the general meaning and explain the specific wording.

Failing that, here in the UK you might take the same Question somewhere like Stormfront… next-best thing to an Apple Store but with reasonable prices.

' "HP Scanner 3" will damage your computer…' is not wording Apple or HP use. If it were genuine, that would at best be Windows-style wording… doubly interesting since malware-merchants tend to wean themselves on Windows.

'this file was downloaded on… an unknown date' is not a detail Apple or HP would be interested in, even if it was their wording. 'from an unknown source' might work - though usually, that's macOS or its affiliates being over-zealous and "warning" the poor User about something that matters not at all.

'Report malware (to Apple) to protect others' might be Windows-style wording, if it were genuine.

PKG_CONFIG_PATH is a environment variable that specifies additional paths in which pkg-config will search for its .pc files.

This variable is used to augment pkg-config's default search path. On a typical Unix system, it will search in the directories /usr/lib/pkgconfig and /usr/share/pkgconfig . This will usually cover system installed modules. However, some local modules may be installed in a different prefix such as /usr/local . In that case, it's necessary to prepend the search path so that pkg-config can locate the .pc files.

The pkg-config program is used to retrieve information about installed libraries in the system. The primary use of pkg-config is to provide the necessary details for compiling and linking a program to a library. This metadata is stored in pkg-config files. These files have the suffix .pc and reside in specific locations known to the pkg-config tool.

To check the PKG_CONFIG_PATH value use this command:

To set the PKG_CONFIG_PATH value use:

To see where pkg-config (version 0.24 or later) searches for installed libraries by default, use the following command:

To add to that path, set the PKG_CONFIG_PATH environment variable. The man file states PKG_CONFIG_PATH is:

A colon-separated (on Windows, semicolon-separated) list of directories to search for .pc files. The default directory will always be searched after searching the path the default is libdir/pkgconfig:datadir/pkgconfig where libdir is the libdir where pkg-config and datadir is the datadir where pkg-config was installed.

The first answer is not technically explicit enough. From the man page (open a terminal, type man pkg-config ):

pkg-config retrieves information about packages from special metadata files. These files are named after the package, and has a .pc extension. On most systems, pkg-config looks in /usr/lib/pkgconfig , /usr/share/pkgconfig , /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig for these files. It will additionally look in the colon-separated (on Windows, semicolon-separated) list of directories specified by the PKG_CONFIG_PATH environment variable.

So the pkg-config program is not in the PKG_CONFIG_PATH directory however, if you install a library, for the information to use it in an automake script to be accessible it needs to be in a directory pkg-config is aware of.

You're trying to build a piece of software, let's say Widget. Widget relies on another library, libcog for the sake of argument. Widget's build process (probably a configure script) is using pkg-config to determine how to use libcog. pkg-config doesn't know anything about libcog.

If libcog isn't installed, that's your problem. There is a good chance that a standard install of libcog will fix the problem. Depending on your system, you may need to install an addition "developer" version of the package it often has "-devel" or "-dev" at the end, so if you install "libcog", you might also need to install "libcog-devel".

If libcog is installed, it's probably not installed in a way that pkg-config can find it. There is probably a libcog.pc file somewhere on your system. For the sake of argument, it's at /opt/cog/lib/pkgconfig/libcog.pc. In that case, you can tell pkg-config about it by setting the PKG_CONFIG_PATH to the directory holding libcog.pc. So in a Bourne shell or similar, something like

Once that's done, re-running the command that failed will hopefully work.

If you install a package via the software sources and not downloading the package on your own, you will get new updates to that package and install them via the Update Manager.

You could just install MYPACKAGE by typing in a terminal:

or by using the software center and searching for MYPACKAGE . But if it's not there go with the source.

/yourprogram/bin in your $PATH or make symlinks to it in

This is only for .tar.* files which have the code pre-compiled but packed into a tar file.

Okay, this is a fairly challenging task for a beginner, but just follow my instructions, and it should be fine.

First off, download the .tar.* file, and save it. Don't open it. (In these examples, I'll be installing the Dropbox Beta build, because I was going to install it anyway, so I figured that I might as well document the installation.)

After you've downloaded your file, (assuming that you saved it to Downloads ,) type the following:

NOTE: use the name of whatever file you downloaded. (e.g., for the Firefox Nightly 19.0a1 64-bit build, you would type sudo cp firefox-19.0a1.en-US.linux-x86_64.tar.bz2 /opt/ )

Now, change to the /opt/ directory, extract the program, and remove the old file:

(again, use the name of the downloaded file. Don't forget the extension.)

Okay, check to see what the extracted folder is called:

you'll get something like this:

Okay, in our example, we installed Dropbox, and the only folder there is called .dropbox-dist . That's probably the folder we want, so plug that in to the next step (add a / to the end, since it's a folder.):

Okay, it's now marked as executable, so it's time to create a symbolic link (this is what allows you to run it from the Terminal):

NOTE: this is sudo ln -s /opt// /usr/bin/ . Be sure that is replaced with the simplified, lower-case version of the program's name (e.g., for Firefox Nightly, type firefox-nightly for the uTorrent server, type utserver . Whatever you type here will be the command that you use whenever running the program from the Terminal. Think of /usr/bin/ as like the PATH variable on Windows systems.)

Okay, you're done. The program is now installed and runnable from the Terminal.
What's this? You say you want to run it from the launcher, AND you want it to have an icon? No problem!

This part is fairly simple:

NOTE: If you're installing OVER a previous installation, use ls -a /usr/share/applications and search for pre-existing .desktop file. Plug that file's name in instead.

Now, here's where you create the icon. Here's good template edit it appropriately.

You may want to leave off the MimeType option completely. That could be very bad if you didn't.

As per this bug, the fix is to use a full path. So this is the correct line in the .ssh/config :

The ProxyCommand should invoke ssh with .exe extension, for example:

The long(?) story

Running ssh -vvv XXX shows:

According to CreateProcess document on MSDN, I guess posix_spawn is calling CreateProcess in a way that lpApplicationName argument must be exact and absolute path. After specifying the .exe suffix, it seems to be fixed.

I got same error but it was because of DISPLAY environment variable set to some value. Once you unset that environment variable, the error went away.

This issue has to do with a bug in the OpenSSH Windows implementaiton. This bug is fixed with release Detailed instructions on how to patch the version can be found here

Since netcat is not available on a default system, the following two entries in the .ssh/config will do the trick (assuming that the local username and the remote username are distinct). : system to login : jumphost
<username> : remote user name on and (if they are distinct [email protected] is needed). If you omit [email protected] in front of the local username is taken.

In both cases login to with: ssh foo

So. First, thanks to @SwAt.Be, he's pushed me to the right way. Second, Magento 2 DI debug is really sucks. I hope the guys from Magento ever fix it.

Some of the core models requires Area to be set.

If you directly inject these models into your custom class constructor, and this class in turn is injected somewhere else, and some class of this chain is injected into the your custom Console Command class, then each run of the php bin/magento will cause 'Area code is not set'.

This is a specificity of Magento 2 Dependency Injection. In Developer mode it executes every constructor code of every injected class before real magento init. You can't see what happened at this moment (notice: it's possible when you manually run setup:di:compile)

How to debug

Just try to run setup:di:compile and try to fix all happened errors.

try to determine which of your custom modules are using Console Command

try to disable injections one by one until the exception is disappear (check by the bin/magento execute)

Found a problem model? Great. Go to the next link of our chain and do p.2 until you'll find the core model, then go to the solution.

When you found the injection that cause this exception (This is usually a model), use the Factory of this model instead and create the model through the Factory method ->create() AFTER the $state->setAreaCode(smth) (below an example). Of course you can just made this with the first model in the chain (Import model in my case):

but it's no good, because this error can be appear not only in the Console.

So I found the last model in the chain, and my fix looks like that:

This answer does not claim to be correct, but this is what my investigation led me to.

4 Answers 4

since you did a make altinstall to install python2.7 you won't have a python-devel package to install so you would need the mod_wsgi to refer to proper python.

Starting httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /etc/httpd/conf.d/wsgi.conf: Cannot load /opt/mod_wsgi2.7/usr/lib64/httpd/modules/ into server: cannot open shared object file: No such file or directory

Because we are not using the same python and we didn't link the module with any particular option to make it look in the correct place, it cannot find , we can change that by making libtool check the correct place.

Starting httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /etc/httpd/conf.d/wsgi.conf: Cannot load /opt/mod_wsgi2.7/usr/lib64/httpd/modules/ into server: /opt/mod_wsgi2.7/usr/lib64/httpd/modules/ cannot open shared object file: Permission denied

That last error is because my system is running selinux and the file has the default context. A quick look at stackoverflow tells me it is an selinux issue.

Watch the video: Δεν είναι δυνατή η ανάγνωση ή η εγγραφή CD. DVD στα Windows 7810