cocos installation: AttributeError: 'dict' object has no attribute 'has_key' - cocos2d-x

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

Related

cant install pygame in pycharm

First of all, I'm new to programming. So,forgive me for my mistakes. I've installed pygame in python IDLE. But when I try to install it in pycharm, this happens:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>pip install pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"?[Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>py -m pip install -U pygame --user
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\downloa
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ARMAN\AppData\Local\T
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>
I get an error. I've updated everything. Found a similar problem here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000435070-Command-python-setup-py-egg-info-failed-with-error-code-1-whatever-package-I-try-to-install-.
But I can't understand the solution. So, please kindly help me.
This isn't my answer, but an answer from here:
Pygame docs recommends that you use Python version 3.6.1 or greater,
so I would suggest you to use the most recent non-beta version. Also,
some pygame wheels are not available to this version yet.
After the python installation make sure its added to your PATH
variable and try to install Pygame using this command given that you
are on windows:
py -m pip install -U pygame --user
If you get a PermissionError then
run the command prompt as administrator.
I hope this helps.

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.

Compress command fails on fresh installation of WireCloud

I cannot set up a basic wirecloud instance anymore. I tried to create a minimum Wirecloud instance like this:
virtualenv venv
source venv/bin/activate
pip install wirecloud
wirecloud-admin startproject prj
cd prj/
python manage.py collectstatic
python manage.py compress --force
Upon the call to compress the static files an error is thrown:
CommandError: An error occurred during rendering /opt/wc/venv/local/lib/python2.7/site-packages/wirecloud/defaulttheme/templates/wirecloud/views/base_plain.html: Error parsing expression at 30:
none if($important, !important)
^
on line 2 of theme/wirecloud.defaulttheme/css/base/z-depth.scss
Traceback:
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/calculator.py", line 167, in parse_expression
ast = getattr(parser, target)()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 110, in goal
expr_lst = self.expr_lst()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 199, in expr_lst
expr_slst = self.expr_slst()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 211, in expr_slst
or_expr = self.or_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 216, in or_expr
and_expr = self.and_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 225, in and_expr
not_expr = self.not_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 236, in not_expr
comparison = self.comparison()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 244, in comparison
a_expr = self.a_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 275, in a_expr
m_expr = self.m_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 290, in m_expr
u_expr = self.u_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 319, in u_expr
atom = self.atom()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 359, in atom
return TernaryOp(expr_lst)
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/ast.py", line 558, in __init__
raise SyntaxError("if() must have exactly 3 arguments")
SyntaxError: if() must have exactly 3 arguments
What is the problem here? I just set up the most basic Wirecloud instance possible. If I do not compress it the same error gets thrown in the browser. Is the latest release of wirecloud broken? Or is it something else?
What do I need to do to get a running version again? Help would be much appreciated since the docker image seems to not be able to get restarted and configurations like other databases and so on are thus not very easy to set up...
Use the just released version 0.9.2 of WireCloud :)
See this github ticket for more details.
We are also updated the docker images but if you continue have problems using it, please create a Github ticket or create a new question on StackOverflow with the details.
Wirecloud seems to not be ready for pyscss version 1.3.5.
A downgrade via ´pip install -I pyscss==1.3.4` will do the trick.

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.

SQLAlchemy mysql dialect error with py2app

I'm having trouble getting SQLAlchemy to work with my compiled app after getting through py2app. I've done this successfully in Windows with py2exe. The following is my setup file:
APP = ['Blah.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,
'includes': ['sip',
'PyQt4._qt',
'sqlalchemy.dialects.mysql',
'MySQLdb',
"gzip"]
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
This appears like it's the right way to do it, as I've seen people use it for sqlite, however I still get this error upon trying to run the app after compile:
sqlalchemy.exc.ArgumentError: Could not determine dialect for 'mysql+mysqldb'
I've recently been trying with PyInstaller and have gotten stuck at pretty much the same spot, albeit with a different error which is the following:
Traceback (most recent call last):
File "<string>", line 96, in <module>
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 480, in doimport
exec co in mod.__dict__
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 480, in doimport
exec co in mod.__dict__
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 4, in __bootstrap__
File "OSX_Installer/Jango/build/pyi.darwin/Jango/out00-PYZ.pyz/pkg_resources", line 882, in resource_filename
File "OSX_Installer/Jango/build/pyi.darwin/Jango/out00-PYZ.pyz/pkg_resources", line 1352, in get_resource_filename
File "OSX_Installer/Jango/build/pyi.darwin/Jango/out00-PYZ.pyz/pkg_resources", line 1363, in _extract_resource
KeyError: '_mysql/_mysql.so'
you probably also need _mysql which should include the native mysql bindings. also, this bindings need the binary mysql libraries to be installed on the target system.
your application would probably be a lot more portable if you used a pure python mysql library, such as pymysql or MySQL Connector/Python (both are supported by sqlalchemy)