Use a library locally instead of installing it
EDIT: This answer is outdated. You should be using VirtualEnv. If you are allergic to third-party software for some reason (in which case, why are you installing libraries?), there is something called venv, that is literally built into python3, so there is no excuse not to use some kind of virtualization. (Most people active in the community prefer VirtualEnv, however. See https://stackoverflow.com/a/41573588/410889.)
VirtualEnv installs a local python interpreter, with a local packages folder and everything. In addition to this entirely solving the issue of administrative privileges, the most important feature of VirtualEnv is that it allows you to keep your environments separate. If you have one project that needs Foo version 2.3 and another that needs Foo version 1.5, you can't have them share the same environment; you have to keep their environments separate with VirtualEnv.
There are a few possibilities:
If you already know how to install Python modules, the default distutils
setup already includes a per-user installation option. Just run python setup.py install --user
instead of python setup.py install
. This is the easiest, since this does not necessitate the addition of any source code.
You could also run the script with the directory of tweepy
as the current working directory.
You could add an environment variable named PYTHONPATH to whatever environment (e.g., the shell) you use to run your script, and make it contain the path to tweepy
.
If all else fails, and you really do want to edit your source code, you'll need to edit sys.path
. sys.path
is a list of locations where Python will look for code.
In your code, write:
import sys
sys.path.append("/path/to/your/tweepy/directory")
import tweepy
PowerShell Use third party module without installing it
That really depends on how you want to deploy your module to other machines. If you want to share it on a network share or distribute a zip package, then you can include these dependencies along with your module. Just put Indented.Common
and Indented.NetworkTools
in one directory with your script definition, like so:
MyModule/
└╴MyModule.psm1
└╴Indented.Common/
└╴IndentedNetworkTools/
Then, you can load these modules directly from MyModule.psm1
(without installing them to a global modules path):
import-module $psscriptroot\Indented.Common\Indented.Common.psm1
import-module $psscriptroot\Indented.NetworkTools\Indented.NetworkTools.psm1
And that's it. This will also work if you have a normal .ps1, not a .psm1 module.
Perhaps a more elegant way would be to use WMF5 PackageManagement. Declare Indented.NetworkTools
as dependencies (NestedModules) in MyModule.psd1
, then publish it on PSGallery. Then, you can just say Install-Module MyModule
on other machines - this will install MyModule
and it's dependencies.
The problem with this approach is that any declared dependencies have to be also available on PowershellGallery (which Indented.*
modules are not).
Related Topics
Create an Array With a Pre Determined Mean and Standard Deviation
Matplotlib Rotate Image File by X Degrees
Python - Converting a List of 2 Digit String Numbers to a List of 2 Digit Integers
Missing 1 Required Positional Argument - Issue
Python - Using Regex to Find Multiple Matches and Print Them Out
Valueerror: Invalid \Escape Unable to Load Json from File
List of the Most Recently Updated Files in Python
Python - Remove Any Element from a List of Strings That Is a Substring of Another Element
How to Get Rid of the B-Prefix in a String in Python
Running Two Python Scripts With Bash File
Django.Db.Utils.Operationalerror: (1045, Access Denied for User '<User>'@'Localhost'
Open() Gives Filenotfounderror/Ioerror: Errno 2 No Such File or Directory
Python Opencv - Add Alpha Channel to Rgb Image
Pandas Concat: Valueerror: Shape of Passed Values Is Blah, Indices Imply Blah2
How to Extract Data from Dictionary in the List