w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Cython c++ example fails to recognize c++, why?
Following the example exactly, on a very similar system to yours, everything works fine for me. But, along with a few other differences (an IndentationError, naming the file rectangle.pyx instead of rect.pyx, …) which turned out not to be relevant to this problem, you also left off this at the top of your Cython file: # distutils: language = c++ # distutils: sources = Rectangle.cpp And if I leave that off, I get the same error.

Categories : C++

pow function in C fails to recognize variable
The operation pow(10, opponent_rating / 400); does not equal to 177827.941004. opponent_rating / 400 == 5 Operations involving two integers will produce an integer,in this case the result 5.25 gets clipped to 5 You should divide with a double to get a double result opponent_rating / 400.0 that is used in the pow function.

Categories : C

JAVAC bug - Fails to recognize class as static (follow-up)
It looks like a compiler bug in JDK 1.4.2 / 1.5 to me. I can't see any obvious explanation for the compiler calling that an error. I tried searching the Java Bugs Database for something similar but couldn't find anything. But that may mean that this is an alternative manifestation of some other bug. The fact that people can't reproduce this with JDK 1.6 or 1.7 most likely means that the problem (whatever it was) has been fixed for a long time. So what can you do about it? Very little, I suspect. If you have an Oracle Java support contract (that covers JDK 1.4), then you could fire off a support request to them and ask for an explanation. But (assuming that this is a bug) they are unlikely to offer you a fix. If you wanted to investigate further, I would suggest a couple of thi

Categories : Java

Powershell Set-AzureDeployment fails with a StorageException
Finally, I found a workaround for my problem. Uploading the package to the blob storage and use the url in the Set-AzureDeployment command works fine: # If the target container does not already exist, create it. $containerState = Get-AzureStorageContainer -Name $containerName -ea 0 if ($containerState -eq $null) { New-AzureStorageContainer -Name $containerName | out-null } Set-AzureStorageBlobContent -File $packageLocation -Container $containerName -Blob $blob -Force| Out-Null $script:packageLocation = (Get-AzureStorageBlob -blob $blobName -Container $containerName).ICloudBlob.uri.AbsoluteUri

Categories : Visual Studio

Sql query in Powershell scheduled job fails to run
I believe that it is because of this line: $SqlQuery = gc sqlquery.sql Assuming that you are executing the scheduled task like this: powershell.exe -file "C:dirmyscript.ps1" When you are running the powershell script as a scheduled job, it starts up in the "C:Windowssystem32" folder. Note: This also happens when you specify the "Start in" directory Therefore when your Get-Content executes, it looks for your SQL query in: "C:Windowssystem32sqlquery.sql" Anytime I am running scripts in scheduled tasks that require access to any files, I always use the full path names for everything because you can't assume where things are started or executed from.

Categories : SQL

Powershell Import-Module fails with DllNotFoundException
-ListAvailable lists all the modules it can find on your machine, but those modules are not necessarily loaded (using import-module). PowerShell 2.0 does not show the exported commands until a module is loaded, but PowerShell 3.0 does. Also see here. If you want to see the exported commands from a loaded module try Get-Module. The results of the command are no reason to believe that the module is not working. I'm the author of the PowerShell GAC module and I want to thank your for trying it out. Please add the complete error message details when loading the module so we can figure out what the problem is. Execute dir ((Get-ItemProperty HKLM:SoftwareMicrosoft.NetFramework -Name InstallRoot).InstallRoot) in both the PowerShell console and the ISE and let me know what results you are get

Categories : Powershell

Executing PowerShell script as pre-build event fails
I would not assume the current directory is set like you're expecting. You're using relative paths and that probably isn't a good idea. You can either pass in a path as a parameter to your script e.g. powershell.exe -file "$(ProjectDir)Scriptsmy-scriptsconcat.ps1" "$(ProjectDir)" -- concat.ps1 -- param($projectDir) if (Test-Path $projectDirScriptsmy-scriptsmyprefix-concatenated.js) { Remove-Item $projectDirScriptsmy-scriptsmyprefix-concatenated.js } cat $projectDirScriptsmy-scriptsmyprefix-*.js > $projectDirScriptsmy-scriptsconcatenated.js Rename-Item $projectDirScriptsmy-scriptsconcatenated.js -newname $projectDirScriptsmy-scriptsmyprefix-concatenated.js If you are on PowerShell v3, you can reference files relative to where your concat.ps1 script resides with the $PSScriptRo

Categories : Javascript

Running PowerShell script from a batch file successful on 32 bit but fails on 64 bit
You are running your script from C:Windowssystem32 and there's no such script (usually this happens when the bat is started with admin privileges ). Change the directory or call it with a full path. The easiest way to fix this - set cd /d %~dp0 at the start of the batch script to change the directory on the location where the script is

Categories : Powershell

Powershell command fails with "Invalid namespace" only when running as script, not in console
Not sure why it works in one and not the other, but I assuming it's something to do with your remote session. Here's a list of commands that do not require a remote session, but rather just take a computer name. http://technet.microsoft.com/en-us/library/dd819505.aspx $password = ConvertTo-SecureString "password" -AsPlainText -Force $cred= New-Object System.Management.Automation.PSCredential ("domainuser", $password ) $server = "servername" $query = "SELECT * FROM Msvm_ComputerSystem WHERE ElementName=$server" $VM = get-wmiobject -query $query -namespace "rootvirtualization" -computername hyperVServer -credential $cred Edited your query concat too.

Categories : Powershell

PowerShell code running as scheduled task fails with Program Files folder
Maybe the execution policy is too restricted for this account. try to set the executionpolicy by adding -executionpolicy unrestricted in the parameters. If that failed, it would help to see the log of the scheduler.

Categories : Powershell

Once SSHd into my windows laptop, Putty doesn't recognize python
Figured it out. I found this link: http://cs.nyu.edu/~yap/prog/cygwin/FAQs.html#bashrc which really helped. I went to the /usr/bin folder, then typed ln -s /cygdrive/c/Python27/python.exe and now I can type "python myfile.py" when ssh'd through PuTTY and it works!

Categories : Python

globally capture, ignore and send keyevents with python xlib, recognize fake input
i found the problem. im almost certain that xtest.fake_input does something weird, because when i send keypresses and -releases manually (with some code i found), it works here is an example, that swallows only the "1"-key on keypress and sends "x" on keyrelease to the focused window: from Xlib.display import Display import Xlib from Xlib import X import Xlib.XK import sys import signal import time display = None root = None def handle_event(event): print "handle!" if (event.type == X.KeyRelease): send_key("x") # from http://shallowsky.com/software/crikey/pykey-0.1 def send_key(emulated_key): shift_mask = 0 # or Xlib.X.ShiftMask window = display.get_input_focus()._data["focus"] keysym = Xlib.XK.string_to_keysym(emulated_key) keycode = display.keysym_t

Categories : Python

python ast module fails in pydev, succeeds in cmdline python
It seems the ast you have imported in PyDev is not the ast module in the standard library, but a package. I guess: There is a __init__.py file in the same directory as your test1.py. You selected "Add project directory to the PYTHONPATH" during the project creation. These two combined, results in that error. The ast module in the standard library is shadowed by this ast package. In cmdline python, this ast package is not in the search path, thus the ast module is imported. If you change test1.py to import ast if __name__ == '__main__': print ast.__file__ I guess the output in PyDev would be C: esearchastast\__init__.pyc

Categories : Python

Passing argument from batch script to PowerShell script fails
Change this command: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command "D: estBluebird_1.2.0_RTMReplaceTagsOnConfigFiles.ps1;REPLACE" > C:Temp.out into this: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -File "D: estBluebird_1.2.0_RTMReplaceTagsOnConfigFiles.ps1" REPLACE > C:Temp.out Is the first command supposed to change the execution policy? If so, you need to specify an actual policy. Set-ExecutionPolicy without any arguments won't work. Besides, it'd be simpler to just add -ExecutionPolicy Bypass to the second command: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -ExecutionPolicy Bypass -File "D: estBluebird_1.2.0_RTMReplaceTagsOnConfigFiles.ps1" REPLACE > C:Temp.out

Categories : Powershell

Python - Powershell
Try first with adding python to your path: $env:Path = $env:Path + ";C:Program FilesPython" Note that the path may differ on your machine. Btw for PS - Python integration you might want to play with IronPython: Embedding IronPython in PowerShell.

Categories : Python

Python trying fails
why arent you using the except keyword try: newbutton['roundcornerradius'] = buttondata['roundcornerradius'] buttons.append(newbutton) except: pass this will try the first part and if an error is thrown it will do the except part you can also add the disered error you want to except a certain error like this except AttributeError: you can also get the excepted error by doing this: except Exception,e: print str(e)

Categories : Python

Calling python with dynamic parameters from PowerShell v1.0
After attacking the problem from a different direction and a colleague pointing out my own abject stupidity, it seems the following is a fairly straightforward solution to the complicated problem above. $inputFilePath = $pathToWorkingFolder + $pathToExtractFolder + 'subs_export.csv' $outputFilePath = $pathToWorkingFolder + $pathToExtractFolder +'subs_export_lat_lon.csv' c:python27python.exe D:PythonPPCsubs.py -i $inputFilePath -o $outputFilePath Just needed some peer review I guess...

Categories : Python

How to determine printer model in powershell or python?
I'm not sure if you've already tried this, but you can check what methods are available via Get-Member: Get-WmiObject Win32_Printer | Get-Member Do any of the following give you what you need? Get-WmiObject Win32_Printer | % { $_.DeviceId } Get-WmiObject Win32_Printer | % { $_.PNPDeviceId }

Categories : Python

How to: Pass Arguments to Python Script via Powershell
Got it! Darn single quotes..... $env:Path += ";c:Program Fileslcpython15"; $env:PATHEXT += ";.py"; $arg1 = "Test3" $arg2 = "Testing" $arg3 = 'c:ProgramDataset_cust_attr.py' python $arg3 $arg1 $arg2

Categories : Python

Python/gtk gtk.gdk.pixbuf_new_from_file() always fails
This works for me: #!/usr/bin/env python # -*- coding: utf-8 -*- import gtk def win_with_image(): pixbuf = gtk.gdk.pixbuf_new_from_file("photo.png") print pixbuf win = gtk.Window(gtk.WINDOW_TOPLEVEL) image = gtk.Image() image.set_from_pixbuf(pixbuf) win.add(image) win.connect("destroy", gtk.main_quit) win.show_all() if __name__ == '__main__': win_with_image() gtk.main() If this doesn`t work for you, try to: start google and type your error and choose the second link (http://aptosid.com/index.php?name=PNphpBB2&file=viewtopic&t=2246), in general this helps almost always. reinstall libglib install gtk (maybe some graphical libs - libpng, libjpeg, f.e.) reinstall python/gtk package fix broken package repository change files permissions

Categories : Python

cron job fails in gae python
I,m pretty sure this error was due to DeadlineExceededError, which I did not run into locally. My scrape() script now does its thing on fewer companies and articles, and does not run into the exceeded deadline.

Categories : Python

posting pic with python with twitpic fails
The README.md file (https://github.com/macmichael01/python-twitpic/blob/master/README.md) says ""Command also requires python-2.7 to use.". From the traceback I see your using Python version 2.6. This could be the problem.

Categories : Python

Test of db key against url parameter fails (Python)
You problem will be the result of uid = User.by_id_name(linkid) won't be a Userid but a User object. its str method will mean that when you log stuff it looks like a uid but it isn't This means the comparisons will fail. You should be comparing str(uid) == linkid for you code to work. to prove this try logging repr(uid) rather than str(uid)

Categories : Python

Python import value if module fails
A python import statement is an expression just like any other Python code. You can wrap your module import in a try...except block, like so: import somemodule try: from someothermodule import Temperature except ImportError,e: Temperature = 20

Categories : Python

XML parser python fails to get element
If you really have '.config' in the string, that would be the problem. That's a string literal using c as one of its characters. Even if you have '.\config' or r'.config', both of which specify a literal backslash, that would still be wrong: $ cat eleme.py import xml.etree.ElementTree as ET root = ET.fromstring(""" <root> <config> source </config> <config> source </config> </root>""") print r'using .config', root.findall('.config') print r'using .\config', root.findall('.\config') print 'using ./config', root.findall('./config') $ python2.7 eleme.py using .config [] using .\config [] using ./config [<Element 'config' at 0x8017a8610>, <Element 'config' at 0x8017a8650>]

Categories : Python

I have Python code for detecting input parameter - How to do similar in Powershell
You use $args in Powershell, similar to sys.argv used in the Python example. Read more here - http://technet.microsoft.com/en-us/library/ff730958.aspx

Categories : Python

System Error on running a powershell command from a python script
Can you try : Watchdog_config = '"C:\Program Files (x86)\Common Files\ibm\icc\cimom\data\wmia.properties"' I'am not confortable with python, I just want to enclose path into double quotes "".

Categories : Python

Python Multiprocess using Pool fails on AWS Ubuntu
The MemoryError means you're running out of system-wide virtual memory. How much virtual memory you have is an abstract thing, based on the actual physical RAM plus swapfile size plus stuff that's paged into memory from other files and stuff that isn't paged anywhere because the OS is being clever and so on. According to your comments, each process averages 0.75GB of real memory, and 4GB of virtual memory. So, your total VM usage is 32GB. One common reason for this is that each process might peak at 4GB, but spend almost all of its time using a lot less than that. Python rarely releases memory to the OS; it'll just get paged out. Anyway, 6GB of real memory is no problem on an 8GB Mac or a 7GB c1.xlarge instance. And 32GB of VM is no problem on a Mac. A typical OS X system has virtually

Categories : Python

Python relative import fails in Maya
as long as Prod is on the python path, you can do this - the safest way, using absolute paths # in PAMod2.py import Prod.PackA.PAMod1 Prod.PackA.PAMod1.Function() or (still safe, easier to type): # in PAMod2.py import Prod.PackA.PAMod1 as Mod1 Mod1.Function() You can reference a sibling package as well. This only works inside a module - you can'd do it interactively ( ie, from the maya script editor) . It's also a going to break if eather PackA or PackB moves # in PAMod2.py from .. import PAMod1 PAMod1.Function() The python docs are here and this is a good SO question on the same (common) topic

Categories : Python

Python 2.7.5 on Cygwin64: requests installation fails
Also ran into the same issues when trying to install requests, all the options on http://docs.python-requests.org/en/latest/user/install/#install did not work. I went to https://github.com/kennethreitz/requests and then clicked on "Download Zip" and I got requests-master.zip.

Categories : Python

Python 3 script using libnotify fails as cron job
You are in the right track. This behavior is because cron is run in a multiuser headless environment (think of it as running as root in a terminal without GUI, kinda), so he doesn't know to what display (X Window Server session) and user target to. If your application open, for example, windows or notification to some user desktop, then this problems is raised. I suppose you edit your cron with crontab -e and the entry looks like this: m h dom mon dow command Something like: 0 5 * * 1 /usr/bin/python /home/foo/myscript.py Note that I use full path to Python, is better if this kind of situation where PATH environment variable could be different. Then just change to: 0 5 * * 1 export DISPLAY=:0 && /usr/bin/python /home/foo/myscript.py If this still doesn't work you need to

Categories : Python

asciidoc fails when called via python subprocess
Try this: asciidoc_call = ["asciidoc","-b", "docbook45", asciidoc_file_name] the other call would call ascidoc with "-b docbook45" as one single option, which won't work.

Categories : Python

Python to JSON Serialization fails on Decimal
It is not (no longer) recommended you create a subclass; the json.dump() and json.dumps() functions take a default function: def decimal_default(obj): if isinstance(obj, decimal.Decimal): return float(obj) raise TypeError json.dumps({'x': decimal.Decimal('5.5')}, default=decimal_default) Demo: >>> def decimal_default(obj): ... if isinstance(obj, decimal.Decimal): ... return float(obj) ... raise TypeError ... >>> json.dumps({'x': decimal.Decimal('5.5')}, default=decimal_default) '{"x": 5.5}' The code you found only worked on Python 2.6 and overrides a private method that is no longer called in later versions.

Categories : Python

Python SAX parser fails to handle  character
Although you can encode these characters, they're still at best "frowned upon". See http://www.w3.org/TR/xml/#NT-Char for a list of "bad" characters. Then, see this 1.1 spec as well, which adds some back as allowed in some cases, as "restricted" characters. If the text legitimately should be able to include these characters, it's wise to encode it first, e.g., with base64 encoding. The receiver thus gets well-formed XML (for XML 1.1, it's not always required but that will make it compatible with 1.0). I had to deal with externally-supplied invalid XML myself once before, where I had no control over the sender. It's pretty messy. In my case I could rely on certain patterns, and hence use regular expressions to "patch away" improprieties, but this is a hack: a workaround done out of d

Categories : Python

How can you cleanup a Python UnitTest when setUpClass fails?
The same way you protect resources elsewhere. try-except: def setUpClass(cls): # ... acquire resources try: # ... some call that may fail except SomeError, e: # cleanup here Cleanup could be as simple as calling cls.tearDownClass() in your except block. Then you can call assert(False) or whatever method you prefer to exit the test early.

Categories : Python

parallel installion of Python 2.7 and 3.3 via Homebrew - pip3 fails
I was having the same problem as you were and I had export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH" in my ~/.bash_profile. Removing that line solved the problem for me. If you have that or something like it in your ~/.bashrc or ~/.bash_profile, try removing it.

Categories : Python

Python dict deserialization works in python2.7, fails in 3.3
According to Python 3 json module documentation: The json module always produces str objects, not bytes objects. ... According to Python 3 sqlite3.register_converter documentation: Registers a callable to convert a bytestring from the database into a custom Python type. ... If you try to load bytesstring json, you get TypeError: >>> json.loads('"0"') '0' >>> json.loads(b'"0"') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.3/json/__init__.py", line 319, in loads return _default_decoder.decode(s) File "/usr/lib/python3.3/json/decoder.py", line 352, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) TypeError: can't use a string pattern on a bytes-like object You should convert

Categories : Python

Python's os.walk() fails in Windows when there are long filenames
In Windows file names (including path) can not be greater than 255 characters, so the error you're seeing comes from Windows, not from Python - because somehow you managed to create such big file names, but now you can't read them. See this post for more details.

Categories : Python

PowerPoint & Python: Editing PPT fails when an image is reached
While your code is not actually working replacing your if with a try catch works fine. This may not be a elegant method tough. import win32com.client, sys Application = win32com.client.Dispatch("PowerPoint.Application") Application.Visible = True Presentation = Application.Presentations.Open(sys.argv[1]) for Slide in Presentation.Slides: for Shape in Slide.Shapes: try: Shape.TextFrame.TextRange.Font.Name = "Arial" Shape.TextFrame.TextRange.Font.Size = "12" Shape.TextFrame.TextRange.Font.Color.RGB = "000000" except: pass Presentation.Save() Application.Quit() What probably happens to you is that the if is always true since an object qualifies as true. Try asking length of the object greater than 0 or something similar.

Categories : Python

Python - Flask assets fails to compress my asset files
To fix this problem install jsmin manually. Just do as follow: pip install jsmin Or as you will: easy_install jsmin I hope i've helped you. Be happy!

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.