Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.7 Error when running localstack #227

Closed
shrishinde opened this issue Aug 2, 2017 · 11 comments
Closed

Python 2.7 Error when running localstack #227

shrishinde opened this issue Aug 2, 2017 · 11 comments

Comments

@shrishinde
Copy link
Contributor

@shrishinde shrishinde commented Aug 2, 2017

I see this issue on Ubuntu. Following are the details,

shrishinde:repos$ DEBUG=1 localstack start
Starting local dev environment. CTRL-C to quit.
Starting mock API Gateway (http port 4567)...
Starting mock CloudWatch (http port 4582)...
Starting mock SES (http port 4579)...
Starting mock Kinesis (http port 4568)...
Starting mock Redshift (http port 4577)...
Starting mock S3 (http port 4572)...
Starting mock CloudFormation (http port 4581)...
Starting mock DynamoDB (http port 4569)...
Starting mock SQS (http port 4576)...
Starting local Elasticsearch (http port 4571)...
Starting mock SNS (http port 4575)...
Starting mock DynamoDB Streams service (http port 4570)...
Starting mock Firehose service (http port 4573)...
Starting mock Route53 (http port 4580)...
Starting mock ES service (http port 4578)...
Starting mock Lambda service (http port 4574)...
Initializing DynamoDB Local with the following configuration:
Port:   4564
InMemory:   true
DbPath: null
SharedDb:   true
shouldDelayTransientStatuses:   false
CorsParams: *

* Running on http://0.0.0.0:4579/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4582/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4577/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4566/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4563/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4560/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4576/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4562/ (Press CTRL+C to quit)
* Running on http://0.0.0.0:4580/ (Press CTRL+C to quit)
[2017-08-02T16:47:27,538][INFO ][o.e.n.Node               ] [] initializing ...
[2017-08-02T16:47:27,608][INFO ][o.e.e.NodeEnvironment    ] [UT9YzFt] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [23.6gb], net total_space [78.6gb], spins? [possibly], types [ext4]
[2017-08-02T16:47:27,609][INFO ][o.e.e.NodeEnvironment    ] [UT9YzFt] heap size [483.3mb], compressed ordinary object pointers [true]
[2017-08-02T16:47:27,610][INFO ][o.e.n.Node               ] node name [UT9YzFt] derived from node ID [UT9YzFtzSaatL0HbGr8jPA]; set [node.name] to override
[2017-08-02T16:47:27,610][INFO ][o.e.n.Node               ] version[5.3.0], pid[10062], build[3adb13b/2017-03-23T03:31:50.652Z], OS[Linux/3.19.0-61-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_131/25.131-b11]
[2017-08-02T16:47:28,231][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [aggs-matrix-stats]
[2017-08-02T16:47:28,231][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [ingest-common]
[2017-08-02T16:47:28,231][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [lang-expression]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [lang-groovy]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [lang-mustache]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [lang-painless]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [percolator]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [reindex]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [transport-netty3]
[2017-08-02T16:47:28,232][INFO ][o.e.p.PluginsService     ] [UT9YzFt] loaded module [transport-netty4]
[2017-08-02T16:47:28,233][INFO ][o.e.p.PluginsService     ] [UT9YzFt] no plugins loaded
[2017-08-02T16:47:29,629][INFO ][o.e.n.Node               ] initialized
[2017-08-02T16:47:29,629][INFO ][o.e.n.Node               ] [UT9YzFt] starting ...
[2017-08-02T16:47:29,791][INFO ][o.e.t.TransportService   ] [UT9YzFt] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2017-08-02T16:47:29,797][WARN ][o.e.b.BootstrapChecks    ] [UT9YzFt] initial heap size [209715200] not equal to maximum heap size [524288000]; this can cause resize pauses and prevents mlockall from locking the entire heap
[2017-08-02T16:47:29,798][WARN ][o.e.b.BootstrapChecks    ] [UT9YzFt] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2017-08-02T16:47:32,848][INFO ][o.e.c.s.ClusterService   ] [UT9YzFt] new_master {UT9YzFt}{UT9YzFtzSaatL0HbGr8jPA}{XNjuGQPgSRGP941x4Seysg}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-08-02T16:47:32,878][INFO ][o.e.g.GatewayService     ] [UT9YzFt] recovered [0] indices into cluster_state
[2017-08-02T16:47:32,882][INFO ][o.e.h.n.Netty4HttpServerTransport] [UT9YzFt] publish_address {127.0.0.1:4561}, bound_addresses {[::1]:4561}, {127.0.0.1:4561}
[2017-08-02T16:47:32,885][INFO ][o.e.n.Node               ] [UT9YzFt] started
ERROR:localstack.services.generic_proxy:Error forwarding request: HTTPConnectionPool(host='127.0.0.1', port=4565): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f359c07b0d0>: Failed to establish a new connection: [Errno 111] Connection refused',)) Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/localstack/services/generic_proxy.py", line 185, in forward
    headers=forward_headers)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 471, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 581, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 481, in send
    raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=4565): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f359c07b0d0>: Failed to establish a new connection: [Errno 111] Connection refused',))

shrishinde:repos$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
shrishinde:repos$ 
shrishinde:repos$ python -c 'import localstack; import os; print os.path.dirname(localstack.__file__)'
/usr/local/lib/python2.7/dist-packages/localstack
shrishinde:repos$ ls -la `python -c 'import localstack; import os; print "%s/infra/dynamodb" % os.path.dirname(localstack.__file__)'`
total 3660
drwxrwsr-x 4 shrishinde staff    4096 Aug  2 16:37 .
drwxrwsr-x 5 shrishinde staff    4096 Aug  2 16:43 ..
-rw-r--r-- 1 shrishinde staff 3713946 Feb 16 23:02 DynamoDBLocal.jar
drwxr-xr-x 2 shrishinde staff    4096 Feb 16 23:02 DynamoDBLocal_lib
-rw-r--r-- 1 shrishinde staff    8644 Feb 16 23:02 LICENSE.txt
-rw-r--r-- 1 shrishinde staff     795 Feb 16 23:02 README.txt
drwxr-xr-x 2 shrishinde staff    4096 Feb 16 23:02 third_party_licenses
@whummer
Copy link
Member

@whummer whummer commented Aug 2, 2017

Thanks for reporting @shrishinde . Looks like the Kinesis API didn't start up properly. Can you please provide a bit more debug info:

node -v
npm -v
ls -la localstack/node_modules/ | grep kinesalite

What happens if you try to start it directly, using this command?

(cd localstack/node_modules/kinesalite; node cli.js)

Loading

@shrishinde
Copy link
Contributor Author

@shrishinde shrishinde commented Aug 3, 2017

shrishinde:repos$ node -v
shrishinde:repos$ npm -v
1.3.10
shrishinde:repos$ ls -al /usr/local/lib/python2.7/dist-packages/localstack/node_modules/ | grep kinesalite 
drwxrwsr-x 7 shrishinde shrishinde 4096 Aug  2 16:37 kinesalite
shrishinde:repos$ cd /usr/local/lib/python2.7/dist-packages/localstack/node_modules/kinesalite; node cli.js
shrishinde:kinesalite$ 

node -v doesn't return any version but when I installed it, I see Unpacking node (0.3.2-7.4)

Loading

@whummer
Copy link
Member

@whummer whummer commented Aug 3, 2017

node -v not returning a version might be a problem. In fact, on some machines the node.js binary is named nodejs rather than node, maybe that's the issue here?

Can you please also post the output of this:

which node
which nodejs
ls -la `which node`

Loading

@shrishinde
Copy link
Contributor Author

@shrishinde shrishinde commented Aug 3, 2017

shrishinde:kinesalite$ which node
/usr/sbin/node
shrishinde:kinesalite$ which nodejs
/usr/bin/nodejs
shrishinde:kinesalite$ ls -la `which node`
lrwxrwxrwx 1 root root 9 Oct 29  2012 /usr/sbin/node -> ax25-node

Loading

@whummer
Copy link
Member

@whummer whummer commented Aug 3, 2017

Thanks, that confirms my suspicion. The underlying problem is described here (see accepted answer): https://stackoverflow.com/questions/21168141/cannot-install-packages-using-node-package-manager-in-ubuntu

Essentially, you need to configure your environment in a way that the command node points to the correct binary (/usr/bin/nodejs).

There are a few options to get this working:

  1. Uninstall the ax25-node package (sudo apt-get remove node). This should remove the symbolic link /usr/sbin/node, and you can then re-link nodejs to node: sudo ln -s /usr/sbin/nodejs /usr/sbin/node.
  2. Install node using the node version manager (nvm). See, for example, here: https://stackoverflow.com/questions/21168141/cannot-install-packages-using-node-package-manager-in-ubuntu/38325376#answer-38325376
  3. simply set an alias in your terminal to make node point to the right binary: alias node=nodejs

Option 3 is probably the least intrusive one. For the other options, please note that these are just suggestions, please handle them with care. Please make sure you know what you are doing before running these commands. Thanks.

EDIT: Option 3 does not work either, because the alias is only valid for the current shell, but not for any sub-shells. Please go with option 1) or 2).

Loading

@shrishinde
Copy link
Contributor Author

@shrishinde shrishinde commented Aug 3, 2017

@whummer Thanks for quick response.
fixed things. Now node -v returns v8.2.1

shrishinde:~$ DEBUG=1 localstack start
Starting local dev environment. CTRL-C to quit.
Starting mock API Gateway (http port 4567)...
Starting mock CloudWatch (http port 4582)...
Starting mock SES (http port 4579)...
Starting mock Kinesis (http port 4568)...
Starting mock Redshift (http port 4577)...
Starting mock S3 (http port 4572)...
Starting mock CloudFormation (http port 4581)...
Starting mock DynamoDB (http port 4569)...
Starting mock SQS (http port 4576)...
Starting local Elasticsearch (http port 4571)...
Starting mock SNS (http port 4575)...
Starting mock DynamoDB Streams service (http port 4570)...
Starting mock Firehose service (http port 4573)...
Starting mock Route53 (http port 4580)...
Starting mock ES service (http port 4578)...
Starting mock Lambda service (http port 4574)...
Initializing DynamoDB Local with the following configuration:
Port:	4564
InMemory:	true
DbPath:	null
SharedDb:	true
shouldDelayTransientStatuses:	false
CorsParams:	*

module.js:487
throw err;
^

Error: Cannot find module 'memdown'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/python2.7/dist-packages/localstack/node_modules/kinesalite/db/index.js:4:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)

Tried different solutions for resolving Error: Cannot find module 'memdown'. Very frustrating first experience with nodejs. Any idea how can I solve this one.

Loading

@whummer
Copy link
Member

@whummer whummer commented Aug 3, 2017

I'd give this a try:

rm -r /usr/local/lib/python2.7/dist-packages/localstack/node_modules
npm install -g npm@latest || sudo npm install -g npm@latest
localstack start

Loading

@shrishinde
Copy link
Contributor Author

@shrishinde shrishinde commented Aug 3, 2017

@whummer your last suggestion has done the trick. Thanks a lot.
Just to summarize following steps solved the problem,

sudo apt-get remove node
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
alias node=nodejs
rm -r /usr/local/lib/python2.7/dist-packages/localstack/node_modules
npm install -g npm@latest || sudo npm install -g npm@latest
localstack start

Loading

@whummer
Copy link
Member

@whummer whummer commented Aug 3, 2017

Thanks for summarizing. Would be great if we could add a few words to the Troubleshooting section of the README. Maybe you find the time to raise a quick PR, would be much appreciated! Cheers

Loading

@whummer whummer closed this Aug 3, 2017
@shrishinde
Copy link
Contributor Author

@shrishinde shrishinde commented Oct 18, 2017

@whummer when I try to push changes to new branch for raising PR, I get below error. Do I need any specific permission? May be I am asking naive question but please help me as this is my start towards contribution to this repo.

ERROR: Permission to localstack/localstack.git denied to shrishinde.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

Loading

@whummer
Copy link
Member

@whummer whummer commented Oct 25, 2017

@shrishinde Please create a fork of the repository in your own account. You can follow the documentation provided here: https://help.github.com/articles/creating-a-pull-request-from-a-fork/ Thanks

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants