Error with XlWings on mac with parallels - python-2.7

I try to open the fibonacci template on my mac using Microsoft Excel from Parallels but I get the following error (xlwings version 0.4.1).
The file is well opened automatically with Microsoft Excel and the error comes.
Has someone any idea on how to correct that ?
In[39]: wb = Workbook(r'/Users/Downloads/fibonacci.zip Folder/fibonacci.xlsm')
Traceback (most recent call last):
File "/Users/anaconda/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 3035, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-39-8750713fa323>", line 1, in <module>
wb = Workbook(r'/Users/Downloads/fibonacci.zip Folder/fibonacci.xlsm')
File "/Users/anaconda/lib/python2.7/site-packages/xlwings/main.py", line 158, in __init__
self.name = xlplatform.get_workbook_name(self.xl_workbook)
File "/Users/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 102, in get_workbook_name
return xl_workbook.name.get()
File "/Users/anaconda/lib/python2.7/site-packages/aeosa/appscript/reference.py", line 498, in __call__
raise CommandError(self, (args, kargs), e, self.AS_appdata)
CommandError: Command failed:
OSERROR: -1708
MESSAGE: Application could not handle this command.
COMMAND: app(u'/Users/Applications (Parallels)/{716d2333-63ae-4f42-a203-ae81a0a171db} Applications.localized/Microsoft Excel.app').workbooks['fibonacci.xlsm'].name.get()

If you want to use the Windows version of Excel from Mac through Parallels, you need to drive things from a Windows based Python installation, too (e.g. from the Windows Command Prompt instead of Mac Terminal).
If instead you want to drive Mac Excel 2011 or 2016 and in case Parallels is giving you a hard time, specify the path of the Mac Excel installation through app_target, see the docs or this question.

Related

I tried to create my first django project(using powershell) but failed to do so because of errors

I am new to django. I wanted to create my first sample project so I followed all the usual ways(as in youtube) and installed python 3.4,pip,django etc. When the environment was set I typed the below command in windows powershell
django-admin startproject mysiteone
and got the below syntax error message(See last para)
My system uses Windows 7 OS. I was unable to find even the version of django i had installed. I dont know why.
I gave these codes in powershell:
django-admin startproject mysiteone
python -m django --version
Error message that I got as a result:
Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 171, in _run_module_as_main "_main_", mod_spec)
File "C:\Python34\lib\runpy.py", line 86, in _run_code exec(code, run_globals)
File "C:\Python34\Scripts\django-admin.exe\_main_.py", line 5, in <module>
File "C:\Python34\lib\site-packages\django\core\management\_init_.py", line 260
subcommands = [*get_commands(), 'help']
SyntaxError: can use starred expression only as assignment target
i had the same problem and i solved by migration to python >= 3.5 , it's an unpacking problem => https://www.python.org/dev/peps/pep-0448/

WindowsError: [Error 2] The system cannot find the file specified pytesseract

I'm trying to run this python code, but it keeps throwing the same error. I'm using pytesseract on a windows machine (coding in pycharm) to scan an image. I made a project on cloud9 that haevily used pytesseract in amazon web services and everything worked fine I am convinced that this is a windows problem. This is all in python 2.7 (this is a small test program I made to debug this same problem in a much bigger project)
Here's my code:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
filename = "Z:\Pycharm Projects\IBM-Waldon-master\screenshots\image.png"
print pytesseract.image_to_string(Image.open(filename))
I've tried making the meat of the code a function and restarting my computer but it still throws this error:
Z:\Python27\interpeter\Scripts\python.exe "Z:/Pycharm Projects/IBM-Waldon-
master/testest.py"
Traceback (most recent call last):
File "Z:/Pycharm Projects/IBM-Waldon-master/testest.py", line 9, in <module>
print pytesseract.image_to_string(Image.open(filename))
File "Z:\Python27\interpeter\lib\site-packages\pytesseract\pytesseract.py", line 193, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)
File "Z:\Python27\interpeter\lib\site-packages\pytesseract\pytesseract.py", line 140, in run_and_get_output
run_tesseract(**kwargs)
File "Z:\Python27\interpeter\lib\site-packages\pytesseract\pytesseract.py", line 111, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "Z:\Python27\Lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "Z:\Python27\Lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Process finished with exit code 1
On Windows, PIL uses whatever program is registered to open a temporary .BMP file. When the program returns, the temporary file is deleted.
By far the most common problem is that the program sends back a return code even before it even opens the file, and the file is deleted before it can be opened. Unfortunately the default viewer in Windows Vista and 7 has this problem; XP used the Microsoft Image and Fax viewer which was OK.
You can use File Explorer to change the program associated with .BMP files.

Pytesseract Image_to_string returns Windows Error: Access denied error in Python

I tried to read the text from the image using Pytesseract.I am getting Access denied message when I run the below script.
from PIL import Image
import pytesseract
import cv2
import os
filename=r'C:\Users\ychandra\Documents\teaching-text-structure-3-728.jpg'
pytesseract.pytesseract.tesseract_cmd = r'C:\Python27\Lib\site-packages\pytesseract'
image=cv2.imread(filename)
gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
gray=cv2.threshold(gray,0,255,cv2.THRESH_BINARY|cv2.THRESH_OTSU)[1]
gray=cv2.medianBlur(gray,3)
filename='{}.png'.format(os.getpid())
cv2.imwrite(filename,gray)
text=pytesseract.image_to_string(Image.open(filename))
print text
cv2.imshow("image",image)
cv2.imshow("res",gray)
cv2.waitKey(0)
when I run the script I am getting below Error
Traceback (most recent call last):
File "F:\opencv\New_folder_3\text_from_image.py", line 17, in <module>
text=pytesseract.image_to_string(Image.open(filename))
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 5] Access is denied
Your code works except the setting of pytesseract.pytesseract.tesseract_cmd. The tesseract_cmd should set to the tesseract executable file installed in your machine.
Here is a sample usage of it.
pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract 4.0.0/tesseract.exe"
The tesseract_cmd is required if no properly search PATH setup in your Windows PC.
Hope this help.
UPDATE:
You need to have tesseract binary installed into your PC before using pytesseract which uses subprocess module to run tesseract in Windows shell from Python.
Click this Tesseract 4.00 alpha to download a 64-bit Windows version and install it. Then setup the PATH and TESSDATA_PREFIX pointing to your tesseract.exe and ~\tessdata directory respectively.
If you need any other language trained data file, you can get it [here].
In case the ~\tessdata directory is not found in your Windows, you can create it manually and copy at least one traineddata file to there, such as eng.traineddata for English.
If tesseract is working, it will return the version information when you type tesseract -v in command prompt as below.

virtualenv is not compatible with this system or executable

I am rather new to Linux (Ubuntu) and installing (Python) packages. I'm having trouble with mkvirtualenv and can not solve it:
~$ mkvirtualenv mysite70
New python executable in mysite70/bin/python
Traceback (most recent call last):
File "/usr/lib/python2.7/site.py", line 562, in <module>
main()
File "/usr/lib/python2.7/site.py", line 544, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python2.7/site.py", line 236, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python2.7/sysconfig.py", line 577, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python2.7/sysconfig.py", line 476, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python2.7/sysconfig.py", line 355, in _init_posix
raise IOError(msg)
IOError: invalid Python installation: unable to open /home/sietse/.virtualenvs/mysite70/local/include/python2.7/pyconfig.h (No such file or directory)
ERROR: The executable mysite70/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/home/usr/.virtualenvs' (should be u'/home/usr/.virtualenvs/mysite70')
ERROR: virtualenv is not compatible with this system or executable
Did I install something wrong?
This is likely a permissions error with your current logged in user on the Linux machine.
Try
sudo mkvirtualenv mysite70
This will often prompt for the password of the root user.
If that does not work, you may want to look at the article below:
http://noelusion.com/2013/Fixing-the-mysterious-virtualenv-error-IOError-invalid-Python-installation/
But note, that the article is a hack on a fairly specific instance.
I think I messed up the installation. I reinstalled Ubuntu, virtualenv etc. It works fine now.
Make sure your username has accents or special characters. If yes, change directory creating environments creating an environment variable WORKON_HOME with value equal to the new path. Ex .: C:\Envs

Appcelerator Titanium wont build projects (after time machine restore)

Ti.SDK 1.6.2
iOS 4.3
I recently got a new system and built it off of a time machine backup of my old system.
When I try to compile and run any app in the simulator I'm getting the following error returned to the console.
[INFO] One moment, building ...
Traceback (most recent call last):
File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/builder.py", line 1342, in <module>
main(sys.argv)
File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/builder.py", line 505, in main
link_version = check_iphone_sdk(iphone_version)
File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/builder.py", line 48, in check_iphone_sdk
output = run.run(["xcodebuild","-showsdks"],True,False)
File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/run.py", line 7, in run
proc = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child
OSError: [Errno 2] No such file or directory
It worked fine yesterday on the old system. I ran a backup before transferring and then installed the new system off of the most recent backup. Not sure why it would work on the old system and not the new.
I ended up reinstalling xcode as the error referenced python. This solved the problem.
try deleting everything in build/iphone. Do NOT delete the build/iphone directory, just everything IN it. Restart Ti Studio and rebuild.