Jump to content


Photo

Chapter 4 - Page 127


  • Please log in to reply
1 reply to this topic

#1 j4mes.c

j4mes.c

    New Member

  • Members
  • Pip
  • 1 posts

Posted 01 April 2013 - 12:12 PM

Just got to page 127 in chapter 4 where you have to use the print_lol function from chapter 2, but I'm getting the error:

Traceback (most recent call last):
  File "/home/james/python/headfirst/chapter4/sketch.py", line 1, in <module>
    import nester
ImportError: No module named 'nester'

It only seems to works if I have nester.py in the same folder as whatever script I'm running (in this case sketch.py).

I have run sdist and installed nester as per instructions in the book:
james@james-Inspiron-1764:~/python/headfirst/chapter2/nester$ python3 setup.py sdist
/usr/lib/python3.2/distutils/dist.py:257: UserWarning: Unknown distribution option: 'pymodules'
  warnings.warn(msg)
running sdist
running check
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

warning: sdist: standard file not found: should have one of README, README.txt

writing manifest file 'MANIFEST'
creating nester_jc-1.4.0
making hard links in nester_jc-1.4.0...
hard linking setup.py -> nester_jc-1.4.0
Creating tar archive
removing 'nester_jc-1.4.0' (and everything under it)
james@james-Inspiron-1764:~/python/headfirst/chapter2/nester$ sudo python3 setup.py install
[sudo] password for james: 
/usr/lib/python3.2/distutils/dist.py:257: UserWarning: Unknown distribution option: 'pymodules'
  warnings.warn(msg)
running install
running build
running install_egg_info
Removing /usr/local/lib/python3.2/dist-packages/nester_jc-1.4.0.egg-info
Writing /usr/local/lib/python3.2/dist-packages/nester_jc-1.4.0.egg-info

It appears to have installed for python 3.2 but IDLE is for python 3.3, so I've done the same as above, but specifying pyhton3.3 instead on python3:
james@james-Inspiron-1764:~/python/headfirst/chapter2/nester$ python3.3 setup.py sdist
/usr/lib/python3.3/distutils/dist.py:257: UserWarning: Unknown distribution option: 'pymodules'
  warnings.warn(msg)
running sdist
running check
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

warning: sdist: standard file not found: should have one of README, README.txt

writing manifest file 'MANIFEST'
creating nester_jc-1.4.0
making hard links in nester_jc-1.4.0...
hard linking setup.py -> nester_jc-1.4.0
Creating tar archive
removing 'nester_jc-1.4.0' (and everything under it)
james@james-Inspiron-1764:~/python/headfirst/chapter2/nester$ sudo python3.3 setup.py install
[sudo] password for james: 
/usr/lib/python3.3/distutils/dist.py:257: UserWarning: Unknown distribution option: 'pymodules'
  warnings.warn(msg)
running install
running build
running install_egg_info
Removing /usr/local/lib/python3.3/dist-packages/nester_jc-1.4.0.egg-info
Writing /usr/local/lib/python3.3/dist-packages/nester_jc-1.4.0.egg-info

but still to no avail, when i try and import nester from any other folder i get this:
james@james-Inspiron-1764:~$ python3.3
Python 3.3.0 (default, Sep 29 2012, 17:14:58) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nester
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'nester'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 4, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 21, in <module>
    import apt_pkg
ImportError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'nester'
>>> 

any ideas???

#2 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 16 April 2013 - 05:07 AM

Instead of "python3.3 setup.py sdist", try "python3.3 setup.py install". See bottom of page 40 for example.

That should make a difference.

--Paul.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users