Windows 10 Rtree installation successful from .whl file, but error when running code - ctypes

I am running Python 3.7, 64bit on Windows 10 and trying desperately to get Rtree running. I use the package Rtree-0.9.1-cp37-cp37m-win_amd64.whl from Christoph Gohlke (https://www.lfd.uci.edu/~gohlke/pythonlibs/).
I have tried for very long to get it to work, but keep on getting the following error message when running a script that uses geopandas.
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\rtree\core.py", line 90, in <module>
rt = ctypes.CDLL(os.path.join(here, 'spatialindex_c.dll'))
File "C:\Python37\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
The installation of the whl-package should include the libspatialindex files, but they are not found when running the code. I tried to use Python 2.7 first to run it, then installed Python 3.7. I've checked all the dependencies and checked whether the "spatialindex_c.dll" files are at the right place, but nothing helps. Would be great to get an answer on that.

Related

Problems runing Street pyghter - 1.2

I'm trying to run this project
on my Raspberry Pi 4 but there is some errors, like some files missing, and variables not defined.
I tried to change and fix the problems but still not working.
Someone have a tutorial to build one from zero or a new version?
In every project creating my own or clone gaves me this error on the terminal:
Hello from the pygame community. https://www.pygame.org/contribute.html /home/pi/Desktop/pygame/main.py:3: RuntimeWarning: use font: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory (ImportError: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory) pygame.font.init() Traceback (most recent call last): File "/home/pi/Desktop/pygame/main.py", line 3, in <module> pygame.font.init() File "/home/pi/.local/lib/python3.7/site-packages/pygame/__init__.py", line 59, in __getattr__ raise NotImplementedError(missing_msg)
I resolve it in Raspberry Pi, setting it from zero, deleting all in the micro SD card and installing again Raspberry Pi OS, the problem was that I tried to install on the terminal the pygame but is already installed on Raspberry Pi, so probably was an error during the installation.

Assertion Error while using stanford-sentiment-treebank-roberta.2021-03-11.tar.gz in ALLENNLP

I have created a virtual ubuntu machine and installed ALLENNLP,
In that and tried example from ALLENNLP demo website
I have executed below code
from allennlp.predictors.predictor import Predictor
import allennlp_models.tagging
predictor = Predictor.from_path("myLocalPath/stanford-sentiment-treebank-roberta.2021-03-11.tar.gz")
predictor.predict("a very well-made, funny and entertaining picture.")
which gave me below error.
>>> predictor.predict("a very well-made, funny and entertaining picture.")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/.local/lib/python3.8/site-packages/allennlp/predictors/text_classifier.py", line 24, in predict
return self.predict_json({"sentence": sentence})
File "/home/.local/lib/python3.8/site-packages/allennlp/predictors/predictor.py", line 54, in predict_json
instance = self._json_to_instance(inputs)
File "/home/.local/lib/python3.8/site-packages/allennlp/predictors/text_classifier.py", line 40, in _json_to_instance
return self._dataset_reader.text_to_instance(sentence)
File "/home/.local/lib/python3.8/site-packages/allennlp_models/classification/dataset_readers/stanford_sentiment_tree_bank.py", line 114, in text_to_instance
assert isinstance(
AssertionError
But when I executed below code
from allennlp.predictors.predictor import Predictor
import allennlp_models.tagging
predictor = Predictor.from_path("myLocalPath/sst-roberta-large-2020.06.08.tar.gz")
predictor.predict("a very well-made, funny and entertaining picture.")
It worked.
Only difference between above two code is version of roberta-large train data
I have installed latest version of ALLENNLP in my virtual machine
I don't have NVIDIA graphic card in my virtual machine could this be a reason?
But then how come other version is working?
Please help
Allen NLP version was the issue it was ALLENNLP 2.1.0, It worked with ALLENNLP version 2.4.0.
Use command "pip install allennlp"
and then "pip install allennlp-models"
instead of "pip install allennlp==[some version] allennlp-models==[some version]"
or make sure you have version greater than or equal to 2.4.0.

Python3 html to pdf

how to convert HTML to PDF in Python3?
Xhtml2pdf does not work in Python3, got error:
import xhtml2pdf.pisa as pisa
Traceback (most recent call last):
File "", line 1, in
File "/home/hound/test/python/test_env/lib/python3.4/site-packages/xhtml2pdf/init.py", line 41, in
from xhtml2pdf.util import REPORTLAB22
File "/home/hound/test/python/test_env/lib/python3.4/site-packages/xhtml2pdf/util.py", line 302
raise Exception, "box not defined right way"
^
SyntaxError: invalid syntax
The best that I found by far is weasyprint.
From the documentation:
from weasyprint import HTML
HTML('http://weasyprint.org/').write_pdf('/tmp/weasyprint-website.pdf')
and it really works that easy. Saved me tons of time (after I wasted time trying to get xhtml2pdf and others to work in python 3 but failed.
I had the same error. Apparently for now xhtml2pdf has Python3 support only in its prerelease version - 0.2b1 (for more info see https://pypi.python.org/pypi/xhtml2pdf). I’ve solved the problem by uninstalling the previous xhtml2pdf version and installing the prerelease version
pip install --pre xhtml2pdf

Error when trying to install Django CMS in virtualenv w/ MySQL on Mac OSX

I am getting the following error when I try to install django CMS with MySQL using virutalenv:
RuntimeError: maximum recursion depth exceeded
/Users/ethan/Sites/env/build/mysql-python/distribute-0.6.28-py2.7.egg
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/Users/ethan/Sites/env/build/mysql-python/setup.py", line 7, in <module>
use_setuptools()
File "distribute_setup.py", line 145, in use_setuptools
return _do_download(version, download_base, to_dir, download_delay)
File "distribute_setup.py", line 125, in _do_download
_build_egg(egg, tarball, to_dir)
File "distribute_setup.py", line 116, in _build_egg
raise IOError('Could not build the egg.')
IOError: Could not build the egg.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/ethan/Sites/env/build/mysql-python
The command I am using for the install is the following:
env/bin/pip install --download-cache=~/.pip-cache -r reqs.txt
And the reqs.txt file looks like this:
django-cms==2.4.1
Django==1.5.1
django-classy-tags==0.4
South==0.8.1
html5lib==1.0b1
django-mptt==0.5.2
django-sekizai==0.7
six==1.3.0
Pillow==2.0.0
django-filer==0.9.4
cmsplugin-filer==0.9.5
django-reversion==1.7
mysql-python==1.2.4
I'm a novice to django (just going through the tutorial) and I cannot find anything in a search that seems to resolve this issue. Anyone have any ideas?
Change your requirement to mysql-python==1.2.5, I had the same problem on a CentOS 6.3 server.
mysql-python v. 1.2.4 has a hard dependency on distribute version 0.6.28. It might not be picking the right version of distribute.
Run this after the virtual env is activated:
easy_install distribute==0.6.28
and you should be good to proceed with
env/bin/pip install --download-cache=~/.pip-cache -r reqs.txt
change requirement to mysql-python==1.2.5 also worked for me on OS X mavericks with pip install

Stanford Tagger in nltk not working due to JVM parameters

I am having a wired error while running following example code snippet
st = StanfordTagger('bidirectional-distsim-wsj-0-18.tagger')
st.tag('What is the airspeed of an unladen swallow ?'.split())
The first line worked properly but second line is giving following error.
Could not create the Java virtual machine.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1- py2.6.egg/nltk/tag/stanford.py", line 51, in tag
return self.batch_tag([tokens])[0]
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1-py2.6.egg/nltk/tag/stanford.py", line 77, in batch_tag
stdout=PIPE, stderr=PIPE)
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1-py2.6.egg/nltk/internals.py", line 166, in java
raise OSError('Java command failed!')
OSError: Java command failed!
I have tried adding .usr/lib/jvm into path but still not working
It wasn't working for me either. So I tried the following and its working perfectly.
st = POSTagger('path-to/stanford-postagger-full-2012-07-09/models/wsj-0-18-left3words.tagger','path-to/stanford-postagger-full-2012-07-09/stanford-postagger.jar')
and use nltk's tokenize method instead of Python's split()
taggedSentence= st.tag(nltk.word_tokenize(sentence))
I see that question is very outdated, but this days I got same error for unknown reason. It gives me a lot of headache. But I found solution.
First, I installed Oracle Java (here is instructions: How To Manually Install Oracle Java on a Debian or Ubuntu VPS)
Now, my python script told me more information on error. It outputs something like:
Forking JVM: error=12, Cannot allocate memory or error=12, Not enough space
Here you can read more about such problem: Forking the JVM
And to avoid that annoying error I need to edit /etc/sysctl.conf and add the following:
vm.overcommit_memory = 1
Then restart system for the change to take effect.