0

I am really new to Linux system and I am currently using Ubuntu linux operation on Oracle VM VirtualBox. I have a few enquiries about using python and its packages.

This operation is already set up with python installed as well as one python package "pytopkapi". After I have modified one sourcecode in the original package, I would like to replace the old code in the installed package with this new one.

Then I typed,

     help()

     help> pytopkapi

and the screen shows:

     Help on package pytopkapi:

     NAME
         pytopkapi

     FILE
         /usr/local/lib/python2.7/dist-packages/pytopkapi/__init__.py

I assumed that /usr/local/lib/python2.7/dist-packages/pytopkapi/ is the install directory and I did found the sourcecode I would like to replace. Then I copied the new sourcecode in to replace the old one. The whole process went alright but from the results, it seems like the new code is not used.

Could someone tell me if this is the right way to replace a sourcecode inside an installed python package? And if it's not, how can I do it?

Yu Deng
  • 1,051
  • 4
  • 18
  • 35
  • Are there .pyc file? Those are pre-compiled versions, and will be used instead of the source code. See http://stackoverflow.com/questions/15839555/when-are-pyc-files-refreshed – sashoalm Jun 24 '14 at 07:28
  • I'm not sure if this helps. Try deleting this .pyc file /usr/local/lib/python2.7/dist-packages/pytopkapi/__init__.pyc . – Ashoka Lella Jun 24 '14 at 07:30
  • 1
    If you're new to linux, i would be *very* careful using `find ... -exec rm -rf`. That's a disaster waiting to happen. – will Jun 24 '14 at 11:15
  • Thanks, I realised that after I typed in, I found it in a https://docs.python.org/2/install/. – Yu Deng Jun 25 '14 at 02:21

1 Answers1

0

Update:

After I seen those comments, I have deleted all .pyc file using:

     sudo find . -name "*.pyc" -exec rm -rf {} \;

Make sure you have set up your work directory for the package folder specifically before you typed in the code!!!

I got this code from https://docs.python.org/2/install/, it will remove all pre-compiled python files under the work directory.

Then I have re-installed this package using:

     sudo python setup.py install

Now if you run your original codes immediately, they might not be working, and say '... module cannot be found'. I just closed my python then reopen it. Everything just went alright.

Hope it can help.

Yu Deng
  • 1,051
  • 4
  • 18
  • 35