ImportError: No module named frenetic
nickycyee opened this issue · 9 comments
I follow the Programmers Guide
install VirtualBox and import the .OVA from http://download.frenetic-lang.org/uservm/frenetic-uservm-current . Then i git clone https://github.com/frenetic-lang/manual
.
after that i frenetic http-controller --verbosity debug
in first terminal
sudo mn --topo=single,2 --controller=remote
in second terminal
python repeater.py
in third terminal but got the error:
Traceback (most recent call last):
File "repeater.py", line 1, in
import frenetic
ImportError: No module named frenetic
so i try sudo pip install frenetic
then python repeater.py
again
Traceback (most recent call last):
File "repeater.py", line 1, in
import frenetic
File "/usr/local/lib/python2.7/dist-packages/frenetic/init.py", line 10, in
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
File "/usr/local/lib/python2.7/dist-packages/tornado/httpclient.py", line 286, in configure
super(AsyncHTTPClient, cls).configure(impl, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/util.py", line 320, in configure
impl = import_object(impl)
File "/usr/local/lib/python2.7/dist-packages/tornado/util.py", line 153, in import_object
obj = import('.'.join(parts[:-1]), None, None, [parts[-1]], 0)
File "/usr/local/lib/python2.7/dist-packages/tornado/curl_httpclient.py", line 24, in
import pycurl # type: ignore
ImportError: No module named pycurl
after that i sudo apt-get install python-pycurl
and python repeater.py
again
Starting the tornado event loop (does not return).
ERROR:tornado.application:Exception in callback <functools.partial object at 0x7fb61cdafd08>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 604, in _run_callback
ret = callback()
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/frenetic/init.py", line 130, in __handle_connect
self.connected()
File "repeater.py", line 9, in connected
self.update( id >> SendToController("repeater_app") )
NameError: global name 'SendToController' is not defined
help me pls இдஇ
The SendToController
function is defined here:
frenetic/lang/python/frenetic/syntax.py
Line 741 in 8a8d863
Is it possible you got an out-of-date version from pip?
I had a go at getting Frenetic up and running today and ran into this issue too. @jnfoster's hunch seems correct. Looks like pip's pulling down an old version, so instead I installed frenetic like so (in the VM):
git clone https://github.com/frenetic-lang/frenetic.git
cd frenetic/lang/python/
pip install .
I then tried to install pycurl with pip, but got an error, so I copied OP and did sudo apt-get install python-pycurl
and was then able to run the repeater.py
app and get a functioning controller!
Just as some general feedback for the maintainers of this project, the installation process in the GitHub readme is a little out of date. It's also potentially confusing to newcomers that the VM doesn't come with the Frenetic Python module pre-installed as the programmers' guide, which OP and I are both following, seems to imply that everything's good to go.
EDIT: There's some relevant information here.
EDIT2: Oh, and the programmers' guide says that the VM's user account is frenetic
, but in the copy of the VM I downloaded it's frenetic-user
.
@Subject22 Thanks! Your comments/critiques are well taken. Sorry for the trouble and thanks for following up so well.
@arjunguha Could you update the pip package? It seems you are the maintainer:
https://pypi.python.org/pypi/frenetic/4.0.0
We should also push a new VM and correct the instructions associated with it.
Will do, thanks @Subject22
I've pushed a new Python package (version 4.1.0). @baxtersa would you regenerate the Frenetic tutorial VM with pip install frenetic
? Once that's done we can close this issue.
@arjunguha I see here that (collectively) you considered packaging the Frenetic VM with Vagrant/Atlas, but eventually decided against it.
Have you considered just making a Vagrantfile available for the Frenetic VM? I would definitely find that useful, as might others. Just a thought 😊
Happy to go into why it would be useful for me. Also happy to have this discussion elsewhere, as this may not be the right place.
I've uploaded the new VM image with the pip frenetic package, should be good to go. I'll work on updating various instructions in the next few days.
I'll do a from-scratch rebuild of the image soon too; when installing the pip frenetic package I was getting a handful of filesystem permissions warnings, so I must have done something wrong when I created the frenetic user last time. When I do that I'll publish the bootstrap script in whatever form I end up creating it.
Any news about updating the VM or is there a better way to get started with Frenetic and NetKAT? The first error I get when running python -m frenetic.examples.repeater
was that there is no module examples installed. So I did this:
cd ~/src/frenetic
git pull
cd ~/src/frenetic/src/lang/python
sudo pip install .
# this complains that requirements are already satisfied, even though
# the package here is different from the one already installed in the VM,
# so I did:
sudo pip install . --upgrade
Now python -m frenetic.examples.repeater
tells me cannot import name singledispatch
and I am very confused because pip list
says that singledispatch (3.4.0.3)
is installed.
Further investigation showed that many files under /usr/local/lib/python2.7/dist-packages/
were there but empty, so I did sudo pip install singledispatch tornado --force-reinstall --upgrade
.
Next surprise, running python -m frenetic.examples.repeater
tells me again no module named examples
, so I installed the frenetic python module again as above, but probably that was just because one needs to be in the directory (as examples are not installed globally, only the frenetic module). Low and behold ...
cd ~/src/frenetic/src/lang/python
sudo pip install . --upgrade
python -m frenetic.examples.repeater
... now works and so does h1 ping h2
🎉
Please please update the instructions 🙏 and maybe put a script or Makefile in the VM which gets the simple repeater example up and running.
And more annoying things about the VM: First, shortly after booting there is a notification about an ubuntu backup tool. Second, after running for a while the unattended upgrade job starts in the background — maybe rather disable all automatic updates? Third, Chrome says it crashed the last time.
Installing from source is best for now. I have updated the instructions and removed all mention of the VM.