Closed Alquimista closed 8 years ago
Same here:
---------------------------------------------------------------------------
WindowsError Traceback (most recent call last)
<ipython-input-14-cd7911670ee8> in <module>()
1 doc.markdown = text
----> 2 print doc.html
C:\Python27\lib\site-packages\pandoc\core.pyc in <lambda>(x, fmt)
33 clean_fmt = fmt.replace('+', '_')
34 setattr(cls, clean_fmt, property(
---> 35 (lambda x, fmt=fmt: cls._output(x, fmt)), # fget
36 (lambda x, y, fmt=fmt: cls._input(x, y, fmt)))) # fset
37
C:\Python27\lib\site-packages\pandoc\core.pyc in _output(self, format)
46 [PANDOC_PATH, '--from=%s' % self._format, '--to=%s' % format],
47 stdin=subprocess.PIPE,
---> 48 stdout=subprocess.PIPE
49 )
50
C:\Python27\lib\subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
677 p2cread, p2cwrite,
678 c2pread, c2pwrite,
--> 679 errread, errwrite)
680
681 if mswindows:
C:\Python27\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
894 env,
895 cwd,
--> 896 startupinfo)
897 except pywintypes.error, e:
898 # Translate pywintypes.error to WindowsError, which is
WindowsError: [Error 2] The system cannot find the file specified
Although pandoc exists and:
os.path.exists(pandoc.PANDOC_PATH)
returns True.
I think I found the problem. I changed core.py:
def _output(self, format):
# print format
import os.path
print PANDOC_PATH, os.path.exists(PANDOC_PATH)
p = subprocess.Popen(
[PANDOC_PATH, '--from=%s' % self._format, '--to=%s' % format],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
)
return p.communicate(self._content)[0]
And now when I run
import pandoc
pandoc.PANDOC_PATH = r'C:\Program Files (x86)\Pandoc\bin\pandoc.exe'
doc = pandoc.Document()
doc.markdown = "Hello Wordl!"
print doc.html
I get a print (before the WindowsError: [Error 2] The system cannot find the file specified)
/Users/kreitz/.cabal/bin//pandoc False
As a quick fix until @kennethreitz (hopefully) approves my changes, if you do pandoc.core.PANDOC_PATH = 'pandoc'
, that will work
I did the same change in my own Pull Request which also adds support for writing PDF and ePUB. Although my Pull Request doesn't have a set_path
function.
Did setting pandoc.PANDOC_PATH actually work correctly for you? Didn't seem to make any difference when I did it, hence the set_path function.
It didn't, so I changed the code to PANDOC_PATH = 'pandoc'
like you did...
Right, with you, so if anyone needs to change it, it won't work, but the default will work out of the box. I'll leave my Pull Request in for now then, as the set_path
sounds like it's still necessary. Sorry for overlapping, hadn't seen that part of your Pull Request.
No problem at all! It is necessary. If you want you can also do a pull-request on my repo and I'll merge it to my pull-request #6, it will save @kennethreitz some work.
Done
This should now be fixed!
collection = OSM_FILE[:OSM_FILE.find('.')] working_directory = '/Users/Anshuman Misra/Downloads/' json_file = OSM_FILE + '.json'
mongoimport_cmd = 'mongoimport -h 127.0.0.1:27017 ' + \ '--db ' + db_name + \ ' --collection ' + collection + \ ' --file ' + working_directory + json_file
if collection in db.collection_names(): print 'Dropping collection: ' + collection db[collection].drop()
print 'Executing: ' + mongoimport_cmd subprocess.call(mongoimport_cmd.split()) on running this WindowsErrorTraceback (most recent call last)
file "c:\users\calcon\desktop\src\pyandoc\pandoc\core.py", line 35, in
(lambda x, fmt=fmt: cls._output(x, fmt)), # fget
File "c:\users\calcon\desktop\src\pyandoc\pandoc\core.py", line 48, in _output
stdout=subprocess.PIPE
File "C:\Python27\lib\subprocess.py", line 679, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] El sistema no puede encontrar el archivo especificado