Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing module in virtualenv directory

new to Python and virtualenv so I'm sure this is a noob question, but running into a strange issue when installing a module I've created into a virtualenv folder.

The directory of my module looks like this:

VideoUploader/
     VideoUploader/
         videouploader.py #main script
         __init__.py
     bin/
         userinfo.py #this is called by the setup.py file to get info from user via the command line during install
         __init__.py
     docs/
     setup.py
     tests/
         videouploader_tests.py
         __init__.py 

Here's my setup.py code:

import json
import os
import sys
sys.path.insert(0, './bin')
import userinfo

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {'description': 'VideoUploader',
    'author': '',
    'url': '',
    'download_url': '',
    'author_email': '[email protected]',
    'version': '0.1',
    'install_requires': ['nose','feedparser','requests','peewee'],
    'packages': [],
    'scripts': ['bin/userinfo.py'],
    'name': 'VideoUploader'
}


setup(**config) 

The directory of my virtualenv looks like this:

NewProject/
    venv/
        bin/
        include/
        library/

I'm unclear on where to drop my module directory so that I can install it in this virtual environment.

I have tried moving it to the venv folder, then cd into the VideoUploader folder and run python setup.py install – but is this the correct location to place the module folder?

After that, from within this directory, I open the Python interpreter and try importing VideoUploader. Everything seems fine, however when I try importing a method in the module (which is in the videouploader.py file), like foo = VideoUploader.assignurl() everything works as expected. But only from within the module folder VideoUploader, so clearly it's not installed correctly. What am I doing wrong here?

like image 810
SeanJarp Avatar asked Jan 27 '26 17:01

SeanJarp


1 Answers

In general, you can run setup.py install from any directory, it isn't necessary to put in in venv directory. The files will be copied to right places automatically. Regarding errors on module import, are you sure that you activated your virtualenv (run source venv/bin/activate) You should do that before installing.

like image 109
svfat Avatar answered Jan 30 '26 13:01

svfat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!