The Question : 355 people think this question is useful I need to install a package from PyPi straight within my script. Maybe there’s some module or distutils (distribute, pip etc.) feature which allows me to just execute something like pypi.install('requests') and requests will be installed into my virtualenv. The Question Comments : Why don’t
The Question : 381 people think this question is useful How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)? The Question Comments : I’m not sure what are you trying to do, but if you want to know which folders are
The Question : 396 people think this question is useful I’ve been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. Now I have been assigned to make a Python wrapper for a REST API. I have absolutely no idea on how to start and I
The Question : 539 people think this question is useful Imagine this directory structure: I’m coding mod1, and I need to import something from mod2. How should I do it? I tried from ..sub2 import mod2 but I’m getting an “Attempted relative import in non-package”. I googled around but found only “sys.path manipulation” hacks. Isn’t
The Question : 1258 people think this question is useful How can I load a Python module given its full path? Note that the file can be anywhere in the filesystem, as it is a configuration option. The Question Comments : Nice and simple question – and useful answers but they make me wonder what
The Question : 884 people think this question is useful How do I import other files in Python? How exactly can I import a specific python file like import file.py? How can I import a folder instead of a specific file? I want to load a Python file dynamically at runtime, based on user input.