
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to install python modules without root access?
If you are not able to install modules on a machine(due to not having enough permissions), you could use either virtualenv or save the module files in another directory and use the following code to allow Python to search for modules in the given directory:
>>> import os, sys >>> file_path = 'AdditionalModules/' >>> sys.path.append(os.path.dirname(file_path)) >>> # Now python also searches AdditionalModules folder for importing modules as we have set it on the PYTHONPATH.
You can also use virtualenv to create an isolated local Python environment. The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform’s standard location is), it’s easy to end up in a situation where you unintentionally upgrade an application that shouldn’t be upgraded. This can also be used in our use case where we cannot install the package on the machine as we dont have the permissions. For more info on virtual env, read the docs: https://virtualenv.pypa.io/en/stable/
- Related Articles
- How to install Python modules in Cygwin?
- How to install libxml2 with python modules on Mac?
- How to install python modules and their dependencies easily?
- How to Install two python modules with same name?
- How do we use easy_install to install Python modules?
- How to install and import Python modules at runtime?
- How to use pip to install python modules in easy way?
- How we can import Python modules without installing?
- How to Install and Configure OpenVPN Access Server?
- What is the most compatible way to install python modules on a Mac?
- How to perform square root without using math module in Python?
- How To Setup SSH Access Without Password
- How to use remote python modules?
- How to check version of python modules?
- How to deploy python modules on Heroku?
