I received a ipython notebook file with the following code and I'm attempting to execute it via Jupyter.
import docx;
from django.utils.encoding import smart_text;
doc = docx.Document('test_file.docx')
I get the following traceback
---------------------------------------------------------------------------
PackageNotFoundError Traceback (most recent call last)
<ipython-input-8-2ff3b55810a7> in <module>()
1 import docx;
2 from django.utils.encoding import smart_text;
----> 3 doc = docx.Document('test_file.docx')
4 statements = [para.text.strip() for para in doc.paragraphs
5 if para.text.strip() != '']
C:\Program Files (x86)\Anaconda2\lib\site-packages\docx\api.pyc in Document(docx)
23 """
24 docx = _default_docx_path() if docx is None else docx
---> 25 document_part = Package.open(docx).main_document_part
26 if document_part.content_type != CT.WML_DOCUMENT_MAIN:
27 tmpl = "file '%s' is not a Word file, content type is '%s'"
C:\Program Files (x86)\Anaconda2\lib\site-packages\docx\opc\package.pyc in open(cls, pkg_file)
114 *pkg_file*.
115 """
--> 116 pkg_reader = PackageReader.from_file(pkg_file)
117 package = cls()
118 Unmarshaller.unmarshal(pkg_reader, package, PartFactory)
C:\Program Files (x86)\Anaconda2\lib\site-packages\docx\opc\pkgreader.pyc in from_file(pkg_file)
30 Return a |PackageReader| instance loaded with contents of *pkg_file*.
31 """
---> 32 phys_reader = PhysPkgReader(pkg_file)
33 content_types = _ContentTypeMap.from_xml(phys_reader.content_types_xml)
34 pkg_srels = PackageReader._srels_for(phys_reader, PACKAGE_URI)
C:\Program Files (x86)\Anaconda2\lib\site-packages\docx\opc\phys_pkg.pyc in __new__(cls, pkg_file)
29 else:
30 raise PackageNotFoundError(
---> 31 "Package not found at '%s'" % pkg_file
32 )
33 else: # assume it's a stream and pass it to Zip reader to sort out
PackageNotFoundError: Package not found at 'test_file.docx'
I uninstalled docx and reinstalled python-docx recently and wondering if that's related, or is this a separate issue?
This means that the specified file ('test_file.docx') does not exist or is not a Word document.
Check that the path is correct and that you can open the document with Word (or LibreOffice or whatever).
You might be missing a path part of the filename. Sometimes it's tricky to know what Python considers the default directory, which is where it goes looking for a filename without a path.
Related
I would like to check the number if issues in a given sentence.
my code is
import language_tool_python
tl = language_tool_python.LanguageTool('en-US')
txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)
Instead of returning the number i am getting error message as shown below.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-1c4c9134d6f4> in <module>
1 import language_tool_python
----> 2 tool = language_tool_python.LanguageTool('en-US')
3
4 text = "Your the best but their are allso good !"
5 matches = tool.check(text)
E:\Anaconda\lib\site-packages\language_tool_python\server.py in __init__(self, language, motherTongue, remote_server, newSpellings, new_spellings_persist)
43 self._update_remote_server_config(self._url)
44 elif not self._server_is_alive():
---> 45 self._start_server_on_free_port()
46 if language is None:
47 try:
E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_server_on_free_port(self)
212 self._url = 'http://{}:{}/v2/'.format(self._HOST, self._port)
213 try:
--> 214 self._start_local_server()
215 break
216 except ServerError:
E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_local_server(self)
222 def _start_local_server(self):
223 # Before starting local server, download language tool if needed.
--> 224 download_lt()
225 err = None
226 try:
E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in download_lt(update)
142 ]
143
--> 144 confirm_java_compatibility()
145 version = LATEST_VERSION
146 filename = FILENAME.format(version=version)
E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in confirm_java_compatibility()
73 # found because of a PATHEXT-related issue
74 # (https://bugs.python.org/issue2200).
---> 75 raise ModuleNotFoundError('No java install detected. Please install java to use language-tool-python.')
76
77 output = subprocess.check_output([java_path, '-version'],
ModuleNotFoundError: No java install detected. Please install java to use language-tool-python.
When I run the code I get no java install detected
How to solve this issue?
I think this is not an issue with the Code itself when I run the code you provided
import language_tool_python
tl = language_tool_python.LanguageTool('en-US')
txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)
I get as result a number in this case
OUT: 8
In the Documentation of the language-tool-python is written:
By default, language_tool_python will download a LanguageTool server .jar and run that in the background to detect grammar errors locally. However, LanguageTool also offers a Public HTTP Proofreading API that is supported as well. Follow the link for rate-limiting details. (Running locally won't have the same restrictions.)
So You will need Java (JRE and SKD). Also it's Written in the Requirements of the library:
Prerequisites
Python 3.5+
LanguageTool (Java 8.0 or higher)
The installation process should take care of downloading LanguageTool (it may take a few minutes). Otherwise, you can manually download LanguageTool-stable.zip and unzip it into where the language_tool_python package resides.
Source:
https://pypi.org/project/language-tool-python/
Python 2.7 - JavaError when using grammar-check 1.3.1 library
I Hope I could help.
from tensorflow.python.saved_model import builder as saved_model_builder
export_path=r'tensorflowservingmodel'
export_version=1
builder = saved_model_builder.SavedModelBuilder(export_path)
signature = predict_signature_def(
inputs={'input': new_model.inputs[0]},
outputs={'output': new_model.outputs[0]})
with K.get_session() as sess:
builder.add_meta_graph_and_variables(
sess=sess,
tags=[tag_constants.SERVING],
clear_devices = True,
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY: signature}
)
builder.save()
print("tensorflow serving.......")
AssertionError Traceback (most recent call
last) in
2 export_path=r'tensorflowservingmodel'
3 export_version=1 ----> 4 builder = saved_model_builder.SavedModelBuilder(export_path)
5 signature = predict_signature_def(
6 inputs={'input': new_model.inputs[0]},
~\Anaconda\lib\site-packages\tensorflow\python\saved_model\builder_impl.py
in init(self, export_dir)
93 raise AssertionError(
94 "Export directory already exists. Please specify a different export " ---> 95 "directory: %s" % export_dir)
96
97 file_io.recursive_create_dir(self._export_dir)
AssertionError: Export directory already exists. Please specify a different export directory: tensorflowservingmodel
Delete this directory 'tensorflowservingmodel', make sure it does not exist before exporting the model.
rm -r tensorflowservingmodel
I figured out the problem l had already created a file called tensorflowservingmodel, that's why the program was saying directory already exist.l had to delete the file directory and re rerun the code.
The code shows following errors:
ACTION REQUIRED: Dependencies libstdc++-6.dll and libgcc_s_seh-1.dll not found.
Ensure user account has write permission to C:\Users\dungeon_master\Anaconda3\envs\gl-env\lib\site-packages\graphlab
Run graphlab.get_dependencies() to download and install them.
Restart Python and import graphlab again.
By running the above function, you agree to the following licenses.
when i try to write get_dependencies() afterwards it shows the errors shown in image
ContentTooShortError Traceback (most recent call last)
<ipython-input-4-9e64085fb919> in <module>()
----> 1 graphlab.get_dependencies()
C:\Users\dungeon_master\Anaconda3\envs\gl-env\lib\site-packages\graphlab\dependencies.pyc in get_dependencies()
39
40 print('Downloading gcc-libs.')
---> 41 (dllarchive_file, dllheaders) = urllib.urlretrieve('http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-libs-5.1.0-1-any.pkg.tar.xz')
42 dllarchive_dir = tempfile.mkdtemp()
43
C:\Users\dungeon_master\Anaconda3\envs\gl-env\lib\urllib.pyc in urlretrieve(url, filename, reporthook, data, context)
96 else:
97 opener = _urlopener
---> 98 return opener.retrieve(url, filename, reporthook, data)
99 def urlcleanup():
100 if _urlopener:
C:\Users\dungeon_master\Anaconda3\envs\gl-env\lib\urllib.pyc in retrieve(self, url, filename, reporthook, data)
287 if size >= 0 and read < size:
288 raise ContentTooShortError("retrieval incomplete: got only %i out "
--> 289 "of %i bytes" % (read, size), result)
290
291 return result
ContentTooShortError: retrieval incomplete: got only 105704 out of 546800 bytes
Well, I faced the same questions 1 hour ago, and I fixed it now.
For the 2 .dll files, you can search the internet to download them, copy them to you directory:C:\Users\dungeon_master\Anaconda3\envs\gl-env\lib\site-packages\graphlab.
In ipython notebook, run import graphlab, and then run graphlab.get_dependencies(). Wait 1 minute, the base package will download.
After the 2 steps, you may restart you computer, then you will find everything back to normal.
The error exists for me as well after the following the above steps. What i realised is that the these two dependencies needs to be extracted in the "cython" folder inside "graphlab" folder. So i copied the same folder from a different installation that was working for me previously and volla.. "import graphlab" was successful. In case anyone needs it, below is the link to the zip of my "cython" folder. Just replace this "cython" folder inside graphlab (Usual location is '/Anaconda2/envs/gl-env/Lib/site-packages/graphlab'. I hope it helps someone
https://drive.google.com/open?id=0B1voSQs3jo7Jc2l6RTBzWGhYUUU
I normally have no problem scouring the web for obscure python packages. However I cannot find this one. Does anyone know what the error is referring too?
Is there an easy way to dig into the source to figure out what modules it wants?
I know I shouldn't be bugging stackoverflow about every missing module I have so is there a method for debugging this myself?
These are the modules i've most recently installed for this project:
blist
beautifulsoup
requests
pymongo
SQLAlchemy
xmltodict
financial_fundamentals
I think the error is coming from SQLAlchemy but the error readout says something about vector_cache
Using the following line:
import financial_fundamentals.accounting_metrics as ac
I get:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-f1aecf47aa1b> in <module>()
----> 1 import financial_fundamentals.accounting_metrics as ac
C:\Python27\lib\site-packages\financialfundamentals-0.2.3-py2.7.egg\financial_fundamentals\accounting_metrics.py in <module>()
65 import financial_fundamentals.edgar as edgar
66
---> 67 #vector_cache.vector_cache
68 def earnings_per_share(required_data):
69 start, end = required_data.index[0], required_data.index[-1]
C:\Python27\lib\site-packages\vector_cache-0.1.0-py2.7.egg\vector_cache\_vector_cache.pyc in vector_cache(user_function)
19 # When the function name or location changes you're going to have to re-cache everything, bummer.
20 metric = user_function.__name__
---> 21 data_store = get_data_store()
22 #wraps(user_function)
23 def wrapper(required_data_df):
C:\Python27\lib\site-packages\vector_cache-0.1.0-py2.7.egg\vector_cache\__init__.py in _get_data_store(cls)
37 except IOError:
38 # no config in home directory
---> 39 return cls._default_data_store(db_dir=home)
40 else:
41 return cls._eval_config_code(code)
C:\Python27\lib\site-packages\vector_cache-0.1.0-py2.7.egg\vector_cache\__init__.py in _default_data_store(db_dir)
43 #staticmethod
44 def _default_data_store(db_dir):
---> 45 from sql_driver import SQLDataStore
46 import os
47 db_file_path = os.path.join(db_dir, 'vector_cache.db')
ImportError: No module named sql_driver
Any ideas?
In [1]: from selenium.firefox.webdriver import WebDriver
In [2]: d=WebDriver()
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/usr/local/selenium-read-only/<ipython console> in <module>()
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/selenium-2.0_dev-py2.6.egg/selenium/firefox/webdriver.pyc in __init__(self, profile, timeout)
48 profile = FirefoxProfile(name=profile)
49 if not profile:
---> 50 profile = FirefoxProfile()
51 self.browser.launch_browser(profile)
52 RemoteWebDriver.__init__(self,
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/selenium-2.0_dev-py2.6.egg/selenium/firefox/firefox_profile.pyc in __init__(self, name, port, template_profile, extension_path)
72
73 if name == ANONYMOUS_PROFILE_NAME:
---> 74 self._create_anonymous_profile(template_profile)
75 self._refresh_ini()
76 else:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/selenium-2.0_dev-py2.6.egg/selenium/firefox/firefox_profile.pyc in _create_anonymous_profile(self, template_profile)
82 self._copy_profile_source(template_profile)
83 self._update_user_preference()
---> 84 self.add_extension(extension_zip_path=self.extension_path)
85 self._launch_in_silent()
86
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/selenium-2.0_dev-py2.6.egg/selenium/firefox/firefox_profile.pyc in add_extension(self, force_create, extension_zip_path)
152 not os.path.exists(extension_source_path)):
153 raise Exception(
--> 154 "No extension found at %s" % extension_source_path)
155
156 logging.debug("extension_source_path : %s" % extension_source_path)
Exception: No extension found at None
Okay, I've gotten past this Exception by manually creating the webdriver-extension.zip file and copying it to the selenium/firefox folder in my site-packages directory.
Everything that follows assumes you have gotten a copy of the source code from http://selenium.googlecode.com/svn/trunk/ (using subversion/svn)
If you have Ruby installed you might be able to run rake firefox (that's Ruby make), which is the way you are supposed to build the zip file. Since I don't have ruby installed, I just looked at the /Rakefile and figured out what was supposed to be in the zip.
Basically you just need to add everything in the /firefox/src/extension/ folder. On windows I added the /firefox/prebuilt/Win32/Release/webdriver-firefox.dll to it as well, but I'm not sure I needed to. (On linux you may need to add the appropriate .so file).
OK, I solved it by discovering that the virtualenv was I installed via macports was "missing",
sudo ln -s `which virtualenv-2.6` /opt/local/bin/virtualenv
then running rake firefox and finally rake firefox_xpi ...
what is the following code doing?
from selenium.firefox.webdriver import WebDriver
d = WebDriver()
a proper webdriver import and firefox instantiation looks like this:
from selenium import webdriver
d = webdriver.Firefox()