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

ImportError: no such module: socket #43

Open
alanjds opened this issue Aug 21, 2018 · 19 comments
Open

ImportError: no such module: socket #43

alanjds opened this issue Aug 21, 2018 · 19 comments
Labels
imported Imported from google/grumpy

Comments

@alanjds
Copy link

alanjds commented Aug 21, 2018

google#299 opened by @ch3ck commented on 25 Apr 2017

How do I get past this error:

Traceback (most recent call last):
  File "./build/bin/grumpc", line 118, in <module>
    sys.exit(main(parser.parse_args()))
  File "./build/bin/grumpc", line 76, in main
    visitor.visit(mod)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
    return getattr(self, visit_attr)(node)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 320, in visit_Module
    self._visit_each(node.body)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 734, in _visit_each
    self.visit(node)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
    return getattr(self, visit_attr)(node)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 287, in visit_Import
    for imp in self.block.root.importer.visit(node):
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
    return getattr(self, visit_attr)(node)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 88, in visit_Import
    imp = self._resolve_import(node, alias.name)
  File "/home/localhost/Documents/Dev/play/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 153, in _resolve_import
    raise util.ImportError(node, 'no such module: {}'.format(modname))
grumpy.compiler.util.ImportError: line 9: no such module: socket


I"m trying to transpile python to Go code on Fedora 25

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by trotterdylan
Wednesday Apr 26, 2017 at 01:51 GMT


From gitter it sounds like this is resolved with:

export GOPATH=$PWD/build
export PYTHONPATH=$PWD/build/lib/python2.7/site-packages

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by trotterdylan
Wednesday Apr 26, 2017 at 03:36 GMT


Ah, I see this issue has been updated. Re-opening until socket module is supported.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by noadmin
Wednesday May 17, 2017 at 16:15 GMT


Hi, I have add "grumpy" package into Conda2.7 site packages =)

	[user@devvm grumpy-master]$ ll /home/user/GIT/rest_client/bin
	total 184
	-rw-r----- 1 user dev 88400 May 15 12:49 argparse.py
	-rw-r----- 1 user dev 67971 May 15 14:23 argparse.pyc
	-rw-r----- 1 user dev     0 May 17 15:46 rest_client.go
	-rw-r----- 1 user dev 12033 May 15 14:46 rest_client.py
	-rw-r----- 1 user dev     0 May 15 13:18 __init__.py
	drwxr-x--- 3 user dev  4096 May 15 14:23 requests
	[user@devvm grumpy-master]$ ll /lib/anaconda2/lib/python2.7/site-packages/ | grep requests
	drwxr-x---  3 user dev    4096 Mar 31 09:52 requests
	drwxr-x---  2 user dev    4096 Mar 31 09:52 requests-2.12.4-py2.7.egg-info
	[user@devvm grumpy-master]$ ll /lib/anaconda2/lib/python2.7/site-packages/ | grep grumpy
	drwxr-x---  4 user dev    4096 May 17 15:46 grumpy
	[user@devvm grumpy-master]$ export PYTHONPATH=/lib/anaconda2/lib/python2.7/site-packages/
	[user@devvm grumpy-master]$ echo $PYTHONPATH
	/lib/anaconda2/lib/python2.7/site-packages/
	[user@devvm grumpy-master]$ /lib/grumpy-master/tools/grumpc /home/user/GIT/rest_client/bin/rest_client.py > /home/user/GIT/rest_client/bin/rest_client.go
	Traceback (most recent call last):
	  File "/lib/grumpy-master/tools/grumpc", line 118, in <module>
		sys.exit(main(parser.parse_args()))
	  File "/lib/grumpy-master/tools/grumpc", line 76, in main
		visitor.visit(mod)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
		return self._visit_one(obj)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
		return getattr(self, visit_attr)(node)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 320, in visit_Module
		self._visit_each(node.body)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 734, in _visit_each
		self.visit(node)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
		return self._visit_one(obj)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
		return getattr(self, visit_attr)(node)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 287, in visit_Import
		for imp in self.block.root.importer.visit(node):
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
		return self._visit_one(obj)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
		return getattr(self, visit_attr)(node)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 88, in visit_Import
		imp = self._resolve_import(node, alias.name)
	  File "/lib/anaconda2/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 153, in _resolve_import
		raise util.ImportError(node, 'no such module: {}'.format(modname))
	grumpy.compiler.util.ImportError: line 6: no such module: requests

but it didn't helps, so I've backed to README and set PYTHONPATH to grumpi site-packages location

	[user@devvm grumpy-master]$ export PYTHONPATH=/lib/grumpy-master/build/lib/python2.7/site-packages
	[user@devvm grumpy-master]$ echo $PYTHONPATH
	/lib/grumpy-master/build/lib/python2.7/site-packages
	[user@devvm grumpy-master]$ /lib/grumpy-master/tools/grumpc /home/user/GIT/rest_client/bin/rest_client.py > /lib/rest_client.go
	Traceback (most recent call last):
	  File "/lib/grumpy-master/tools/grumpc", line 118, in <module>
		sys.exit(main(parser.parse_args()))
	  File "/lib/grumpy-master/tools/grumpc", line 76, in main
		visitor.visit(mod)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
		return self._visit_one(obj)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
		return getattr(self, visit_attr)(node)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 320, in visit_Module
		self._visit_each(node.body)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 734, in _visit_each
		self.visit(node)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
		return self._visit_one(obj)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
		return getattr(self, visit_attr)(node)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 287, in visit_Import
		for imp in self.block.root.importer.visit(node):
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 41, in visit
		return self._visit_one(obj)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/pythonparser/algorithm.py", line 32, in _visit_one
		return getattr(self, visit_attr)(node)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 88, in visit_Import
		imp = self._resolve_import(node, alias.name)
	  File "/lib/grumpy-master/build/lib/python2.7/site-packages/grumpy/compiler/imputil.py", line 153, in _resolve_import
		raise util.ImportError(node, 'no such module: {}'.format(modname))
	grumpy.compiler.util.ImportError: line 6: no such module: requests

Any thoughts how I can convert code to Go? Or I should wait for request lib to be added to supported list...

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by jhollar
Wednesday May 24, 2017 at 14:34 GMT


any ETA when the ImportError - no such module: socket will be resolved?

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by alanjds
Friday May 26, 2017 at 04:02 GMT


Heh... The roadmap says "stdlib on July 2017", but I only see it happening if more people put hands on.

(What I mean is: please help if you can)

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by corona10
Friday May 26, 2017 at 05:33 GMT


Yeah, we need more people to work on this project with concrete load map.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by cclauss
Friday May 26, 2017 at 05:58 GMT


My sense is that a big part of the difficulty in recruiting contributions to this project is because it focuses on legacy Python at a time when zero percent of the Python community innovation is going into Python 2.7. Focusing on transpiling Python 2.7 when everyone else is working towards Python 3.7 is only a setup for a series of efforts to catch up to the current state of the art.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by alanjds
Friday May 26, 2017 at 14:34 GMT


@cclaus I still need working stuff to keep working, but a working Py27 can be a trampoline for a working Py3X. Would it gain more traction if the roadmap have one more point "Py3k Compliance" over the existing ones? (honest question)

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by trotterdylan
Tuesday May 30, 2017 at 15:36 GMT


Just a quick update on socket functionality: I have a rough working socket module here: trotterdylan@a3ead81

Based on that work, BaseHTTPServer works as expected, which is a good sign. There's a bunch of different parts that went into this and I need to break them out into individual PRs, which I'll do over the next week or two.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by JockDaRock
Tuesday Oct 17, 2017 at 03:48 GMT


@alanjds in answer to your question on May 26th... I say the answer is yes

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by JockDaRock
Tuesday Oct 17, 2017 at 03:50 GMT


@alanjds what about @trotterdylan 's code changes? was the socket library not added?

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by alanjds
Tuesday Oct 17, 2017 at 14:08 GMT


@JockDaRock I am not tracking this specifically. I am focused on #30 (print statement misbehaviour), that leads to PRs google#302 google#303 google#304 for now.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by alanjds
Tuesday Oct 17, 2017 at 14:12 GMT


@cclauss Btw, Python 3 support is on the roadmap. Was added some months ago.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by RodCardenas
Wednesday Mar 21, 2018 at 20:48 GMT


Did anything ever happen with this?
grumpy.compiler.util.ImportError: line 5: no such module: socket

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by cclauss
Wednesday Mar 21, 2018 at 21:08 GMT


Also, is there and update on https://github.com/google/grumpy/wiki/Roadmap ?

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by alanjds
Thursday Mar 22, 2018 at 12:42 GMT


@cclaus We are near to stale, in my opinion. In last 10 months 20+ PRs were merged, but just one of it in the last 6 months.

Talking for myself, I do think it is hard to contribute because Python modules need Go tests to count for coverage. I was working on this but stopped to wait Go 1.10 and had not got back after.

Another thing hindering my progress is the organization of the internal tooling. Is not usable/testable/importable outside of the build folder and environment. I am working on this to have a pip-installable grumpy CLI tool as a "near drop-in replacement of CPython" as possible. But this got uncovered more incompatibilities with CPython import sysyem.

I do think that, after this two got fixed and PEP-3147 got implemented, there could be an speedup on the development because of ease of installing and testing for newcomers.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by alanjds
Thursday Mar 22, 2018 at 12:50 GMT


I still think is possible to met the "Whole CPython unit test suite runs without errors (goal: Sept 2017)" before Nov 2018 or faster, because of the progress I got on the CLI and PEP-3147 on the last few weeks.

For myself, the trick was to set an Android development environment. Now I do had coded about 1:30 hours per day during subway commuting 👍. Weird, but it's how I am rolling it.

@alanjds alanjds added the imported Imported from google/grumpy label Aug 21, 2018
@andgrew
Copy link

andgrew commented Dec 17, 2018

Hi, I looked at the status of the socket that @trotterdylan made in 2017. It works, and I managed to take from its branch only the implementation of a socket (without code changes). I do not know how to add this to the grumpy tests? And I don’t like how golang version of raw socket bind work, it is not as easily clean as CPython version. What do you think, it seems to me better to add to the project, but to decide the accuracy already in the process?

@alanjds
Copy link
Author

alanjds commented Dec 17, 2018

@andgrew This would help a lot. Please fork a branch from master and send a PR, even if work-in-progress. We can make tests and merge when ready.

@alanjds alanjds pinned this issue Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported Imported from google/grumpy
Projects
None yet
Development

No branches or pull requests

2 participants