Virtualenv is not allowing me to use ImageHorizonLibrary and SwingLibrary in robotframework at the same time - swing

My bash_profile is set to the following:
export PATH=/Users/nimam/jython2.7.0/bin:/opt/local/bin:/opt/local/sbin::/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I need to include jython as I am running the swinglibrary for the robotframework, but I would like to include ImageHorizonLibrary as well. However, i am currently not able to run the ImageHorizonLibrary. I get the following error.
[ ERROR ] Error in file '/Users/nimam/swinglibrary-demo/read_attributes.robot': Importing test library 'ImageHorizonLibrary' failed: ImportError: No module named ImageHorizonLibrary
Traceback (most recent call last):
None
PYTHONPATH:
/Users/nimam/jython2.7.0/bin
/Users/nimam/jython2.7.0/Lib
__classpath__
__pyclasspath__/
/Users/nimam/jython2.7.0/Lib/site-packages
CLASSPATH:
/Users/nimam/jython2.7.0/jython.jar
Rotarran-2.0.8-standalone.jar
If I comment out the export PATH in the bash_profile, it recognizes the ImageHorizonLibrary but not the SwingLibrary. I get the following error:
[ ERROR ] Error in file '/Users/nimam/swinglibrary-demo/read_attributes.robot': Importing test library 'SwingLibrary' failed: ImportError: No module named SwingLibrary
Traceback (most recent call last):
None
PYTHONPATH:
/usr/local/bin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Users/nimam/Library/Python/2.7/lib/python/site-packages
/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
I have a feeling I can solve this by playing around with the virtualenv. Please let me know if there is a way I can run both libraries at the same time.

Related

I am encountering module loading problem in mysql

I will work with mysql, but it gives this error anyway. I did delete the module but it did not change, I loaded it differently, I could not solve the modules.
Traceback (most recent call last):
File "C:\Users\INAL\Desktop\Son Scriptler\mysql\mysql.py", line 1, in <module>
import mysql.connector
File "C:\Users\INAL\Desktop\Son Scriptler\mysql\mysql.py", line 1, in <module>
import mysql.connector
ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package
You might not have the mysql-connector did you try installing it using pip?
pip3 install mysql-connector
The problem was that my project name was mysql.py and I solved the problem by changing the project name.

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

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.

How do I connect Airflow to SQLite locally?

I'm trying to try out Airflow for the very first time and I'm trying to connect it to a local SQLite database. But I can't seem to get my head around on how to actually do it.
I've read up on Airflow's document, Set my executor to LocalExecutor and set up my sql_alchemy_conn to sqlite:////home/myName/Programs/sqlite3/DatabaseName.db but it doesn't seem to work as it throws an
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 21, in <module>
from airflow import configuration
File "/usr/local/lib/python2.7/dist-packages/airflow/__init__.py", line 35, in <module>
from airflow import configuration as conf
File "/usr/local/lib/python2.7/dist-packages/airflow/configuration.py", line 520, in <module>
conf.read(AIRFLOW_CONFIG)
File "/usr/local/lib/python2.7/dist-packages/airflow/configuration.py", line 283, in read
self._validate()
File "/usr/local/lib/python2.7/dist-packages/airflow/configuration.py", line 169, in _validate
self.get('core', 'executor')))
airflow.exceptions.AirflowConfigException: error: cannot use sqlite with the LocalExecutor
error when I tried to run airflow initdb. I tried to google around and tried vipul sharma's solution found here and set the value of my sql_alchemy_conn to mysql://:#localhost:3306/ but it still doesn't work as it throws an
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'myName'#'localhost' (using password: NO)")
error. I know that the answer should be really simple but I really don't understand how to so I hope you can guide me through on what to do/read.
Use SequentialExecutor
"This executor will only run one task instance at a time, can be used for debugging. It is also the only executor that can be used with sqlite since sqlite doesn’t support multiple connections." airflow documentation
You just didn't need to change to LocalExecutor, change it back to SequentialExecutor, change sql_alchemy_conn to point to sqlite:////home/myName/Programs/sqlite3/DatabaseName.db and stop airflow services (webserver, scheduler).
Execute airflow initdb then start up the services again.
Hopefully that works.

cocos installation: AttributeError: 'dict' object has no attribute 'has_key'

I am following the tutorial on my mac. I have all env paths set correctly but when I start a new project I am getting an error.
I have 2 pythons installed 3.4 and 2.7; is it a reason why I have a problem?
I wrote:
cocos$ cocos new HelloWorld -p com.myname.HelloWorld -l cpp -d / Users/dev/cocos/cocosProjects/HelloWorld
and I received the following error:
Traceback (most recent call last):
File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos.py", line 904, in
if not _check_python_version():
File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos.py", line 868, in _check_python_version
print(MultiLanguage.get_string('COCOS_PYTHON_VERSION_TIP_FMT') % (major_ver, minor_ver))
File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/MultiLanguage.py", line 52, in get_string
fmt = cls.get_instance().get_current_string(key)
File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/MultiLanguage.py", line 46, in get_instance
cls.instance = MultiLanguage()
File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/MultiLanguage.py", line 100, in init
if self.cfg_info.has_key(cur_lang_key):
AttributeError: 'dict' object has no attribute 'has_key'
I installed python2.7.11 once again and since then I could use cocos new to build a new project; aliasing python as python2 did not work before; I still have access to my 3.4 version for other applications but 2.7 is my default one which was the problem before.
I hope it will help those who have similar problem.
thank you all for having a look

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.