I've tried searching for this but can't understand the answers that I've seen.  I'm relatively new to Python (2.7) and am the only person at my org who uses it. They're sunsetting one of our virtual environments, and the one which will remain doesn't have any of the necessary third party packages to basically do anything. I need to copy all of the package folders (from 'Python27\Lib\site-packages') to a shared network drive so they're not lost. I've copied the entire Python27 folder over to a shared drive (T:) and want to run them using the copy of Python27 on the new virtual environment (C:)  I want to modify my scripts to import these packages from the networked drive.   The answers I'm seeing for this are similar to:  from application.app.folder.file import func_name   However, this isn't helpful to me, I guess I'm just too stupid to understand it. Lets say I want to import the babel package from the copy I made on T:. The above has me thinking I need to enter something like   from 'T:\foo\Python27\Lib\site-packages' import babel   or   from 'T:\foo\Python2y7\Lib\site-packages\babel' import babel   but every variation of this I try gives syntax errors. Additionally I'm confused, because the examples I see show people pointing to literal '.py' files, but none of these packages have an actual '.py' file of the same name as the package (they all have init files within their individual folders, and lots of other randomly named .py files).  Can someone, in plain english, using filepath examples, show me how to do this? I'm very confused by the long answers and fake example paths, I would love a literal absolute path starting with 'T:\', as answers like   from packA.subA.sa1 import helloWorld   confuse the crap out of me (what is packA? what is subA? is helloWorld the name of the actual package, the name of the folder within site-packages, or the name of a .py file within a folder?)  Unfortunately I'm unable to use PIP or any other third party libs that might make this easier, as the new VDE doesn't have anything but stock 2.7 packages.   I'm sorry for being so dumb, I stayed late and created a StackOverflow account just for this, would really appreciate a hand holding.
7325
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.
52190
How to install and how to compile networkx python on QGIS?  I always get an error that no module named networkx in the console of QGIS I copied the file networkx in C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages and there are not change.
113294
I am writing a Quake 1 .BSP import script with python and I want to extract the textures from the .BSP so that the mesh can be textured. However, the textures are paletized (instead of a color, only an index into a palette is stored for each pixel) and the palette is not contained in the .BSP.   I'd like to include the palette in a file with my script, and load it from the script at run time. However, I don't know how to get the path to the palette file, so I can't load it. Is there a way to get the path my script is running in? I've tried using just the file name of the palette, but it didn't work.  p.s. I know I could store the palette in a python file, but I'd rather use the original .PAL format so that users can swap it for another palette if desired.
86761
Yeah, I did this, it was stupid.  I did not know it will pull its dependencies with it, I just wanted to install python 2 and 3 from scratch (because of this problem: ).  Now, I still can use my terminal, checked these answers:      However after running sudo apt-get install ubuntu-desktop I get these errors:  Setting up python-ldb (2:1.1.24-1ubuntu3) ... /var/lib/dpkg/info/python-ldb.postinst: 6: /var/lib/dpkg/info/python-ldb.postinst: pycompile: not found dpkg: error processing package python-ldb (--configure):  subprocess installed post-installation script returned error exit status 127 No apport report written because MaxReports is reached already                                                               Setting up python-tdb (1.3.8-2) ... /var/lib/dpkg/info/python-tdb.postinst: 6: /var/lib/dpkg/info/python-tdb.postinst: pycompile: not found dpkg: error processing package python-tdb (--configure):  subprocess installed post-installation script returned error exit status 127 No apport report written because MaxReports is reached already                                                               dpkg: dependency problems prevent configuration of python-samba:  python-samba depends on python-crypto; however:   Package python-crypto is not configured yet.  python-samba depends on python-ldb (&gt;= 1.1.2~); however:   Package python-ldb is not configured yet.  python-samba depends on python-tdb; however:   Package python-tdb is not configured yet.  dpkg: error processing package python-samba (--configure):  dependency problems - leaving unconfigured No apport report written because MaxReports is reached already                                                               Processing triggers for libc-bin (2.23-0ubuntu7) ...  Errors were encountered while processing:  mercurial-common  python-crypto  python-dnspython  python-ldb  python-tdb  python-samba E: Sub-process /usr/bin/dpkg returned an error code (1)   What is the way to restore these dependencies (16.04 LTS)?
26699
Imagine that you want to develop a non-trivial end-user desktop (not web) application in Python. What is the best way to structure the project's folder hierarchy?  Desirable features are ease of maintenance, IDE-friendliness, suitability for source control branching/merging, and easy generation of install packages.  In particular:   Where do you put the source? Where do you put application startup scripts? Where do you put the IDE project cruft? Where do you put the unit/acceptance tests? Where do you put non-Python data such as config files? Where do you put non-Python sources such as C++ for pyd/so binary extension modules?
34235
I have a single python script that I want to distribute as a deb package. It is a  which shows local date in Unity panel. I did follow  but I could not create a deb package because it fails.   Can someone give me a step-by-step instruction on what I should do? As far as I know this script depends on python-appindicator.   NOTE: I do not want any links to Debian/Ubuntu packaging instructions. I have seen most of them. I don't find them beginner friendly.
21007
How do I import a Python module given its relative path?  For example, if dirFoo contains Foo.py and dirBar, and dirBar contains Bar.py, how do I import Bar.py into Foo.py?  Here's a visual representation:  dirFoo\     Foo.py     dirBar\         Bar.py   Foo wishes to include Bar, but restructuring the folder hierarchy is not an option.
110191
The default backup app doesn't work properly.  I searched in the web and my Anaconda2 seems to be the problem but I still want it as my primary Python.  If I run in the console:  duplicity --version   The output is:  File "/usr/bin/duplicity", line 61, in &lt;module&gt;     from duplicity import log ImportError: No module named duplicity   How can I fix it and still use Anaconda2 as my primary python shell?
9000
I'm trying to install python3 for one of remote hosting over ssh. I don't have root access. Installation was done with:  wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz tar xvzf Python-3.4.3.tgz ./configure --prefix=$HOME/.local make make install   This installs Python 3, however in the end of installation this error occurs:  File "/home/someusername/Python-3.7.0/Lib/ctypes/__init__.py", line 7, in &lt;module&gt;     from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'   python3 is installed, but pip install failed. After some research it seems that libffi is missing. After using wget to obtain libffi-3.2.1, it is installed with:  ./configure --prefix=$HOME/.local make make install   This shows it is installed:  someusername@a2plcpnl079 [~/.local/lib]$ ls ./  ../  libffi-3.2.1/  libpython3.7m.a*  pkgconfig/  python3.7/ someusername@a2plcpnl079 [~/.local/lib]$ cd libffi-3.2.1/ someusername@a2plcpnl079 [~/.local/lib/libffi-3.2.1]$ ls ./  ../  include/ someusername@a2plcpnl079 [~/.local/lib/libffi-3.2.1]$ cd include someusername@a2plcpnl079 [~/.local/lib/libffi-3.2.1/include]$ ls ./  ../  ffi.h  ffitarget.h someusername@a2plcpnl079 [~/.local]$ cd lib64 someusername@a2plcpnl079 [~/.local/lib64]$ ls ./  ../  libffi.a  libffi.la*  libffi.so@  libffi.so.6@  libffi.so.6.0.4*   Now it is necessary to reconfigure the build of python-3.7.0 so it uses the local libffi. I tried a number of variations but still can't install pip.  # .bash_profile  # Get the aliases and functions if [ -f ~/.bashrc ]; then         . ~/.bashrc fi  # User specific environment and startup programs  PATH=$PATH:$HOME/.local/bin:$HOME/bin  export PATH export HISTTIMEFORMAT="%d/%m/%y %T " export PATH="$HOME/.local/bin:$PATH" export LD_LIBRARY_PATH=$HOME/.local/lib64   Something like this was attempted:  $ ./configure --with-system-ffi --prefix=$HOME/.local LDFLAGS="-L/home/someusername/.local/lib64" LIBS="-L/home/someusername/.local/lib"   The same error occurred, so the question is how to correctly invoke Python-3.7.0 configure to use the local libffi library in order to fully install python?
61305
When I run my script outside ArcGIS it works because during execution script uses a GDAL and OGR modules from osgeo. When I use script as a tool in ArcGIS it does not work. In PySripter I can import all modules and it work. In Python Window in ArcGIS I cannot import because I get this error:     Parsing error SyntaxError: invalid syntax (line 2)    import ogr   Runtime error    Traceback (most recent call last):     File "", line 1, in      File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\ogr.py", line 26, in        _ogr = swig_import_helper()     File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\ogr.py", line 22, in swig_import_helper       _mod = imp.load_module('_ogr', fp, pathname, description)   ImportError: DLL load failed:   In the case when I import  gdal in ArcGIS Python Window I do not get this error. How to force arcgis to import ogr and use it in ModelBuilder or Script?? I check a lot of solutions includin reinstallation, changing and adding environment variables. I checked :       and I still do not have a good solution. Any idea?  UPDATE: I also try use direct importing in my script: import imp ogr = imp.load_source('ogr', 'c:\Python27\Lib\site-packages\osgeo\ogr.py' and I get the same error. If I use this method in standalone script it works.
107466
I have played around a lot with my Python installations (2 and 3) and installed a bunch of packages, some using apt-get, but most using pip. I have also upgraded many apt-installed packages with pip to a newer version.  My question is: How can I reverse all those changes, remove all pip-installed Python packages and just keep the default set of preinstalled packages in their default repository version, plus those installed by apt-get but only as dependency of other software, always downgrading to the repository version if necessary.  I want to do this to have a tidied up Python environment for the system and have my modifications in virtualenvs only.  Is that possible without a system reinstall? How would I approach it?
64705
Currently, when I type "python" at the terminal I get v2.6 which is all fine and dandy but how can I set it to use v3.1 instead?  Is there a "path" variable out there somewhere that I can change like windows?  EDIT: I already have python3 installed and up and running.  I just want to know how to set it as the shells default python version.
17598
How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?  I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.
106341
In order to reduce copy-pasting, I want to create an environment that will produce a two-column table with headers and two listings in different languages, like below:  \begin{tabular}{l l} Python &amp; Haskell \\ \hline \\ \lstset{language=Python} \begin{lstlisting} A \end{lstlisting} &amp; \lstset{language=Haskell} \begin{lstlisting} B \end{lstlisting} \end{tabular}   I want to use it like below, hiding everything but code:  \begin{comparison} A \vs B \end{comparison}   So far I tried making two new environments (instead of a \vs command inside) with \lstnewenvironment, where first environment had \tabularx command and second \endtabularx. I also tried creating normal \newenvironment for this tabular, &amp; for \vs command and manually inserting \begin{lstlistings} and \end{lstlistings} with code, but it stopped compiling when I put lstlistings inside.  How can I create such an environment?  EDIT: The most compact version I've came up with until now is  \newenvironment{comparison} {\begin{parcolumns}[nofirstindent,distance=0pt,colwidths={1=0.35\textwidth}]{2}} {\end{parcolumns}}  \lstnewenvironment{python} {Python \lstset{language=Python,frame=t}} {}  \lstnewenvironment{haskell} {Haskell \lstset{language=Haskell,frame=t}} {}   which is used like that:  \begin{comparison} \colchunk{ \begin{python} A \end{python} } \colchunk{ \begin{haskell} B \end{haskell} } \end{comparison}   I'm still unable to hide \colchunk{} within python or haskell environments.
89246
When I eventually upgrade to 11.04 I will need to install Python 2.6 for development purposes. The 11.04 default is 2.7. Can I just install the python2.6 package alongside the default python package? I don't want anything else to depend on it, I need it for only one purpose. I will be using Distribute and virtualenv to install any further dependencies for Python 2.6.
11160
I am trying to make a virtual environment for the development of my Django application. The commando's which I am using:   vagrant@vagrant:/var/www/djangogirls$ python3 -m venv myvenv The virtual environment was not created successfully because ensurepip is not available.  On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.      apt-get install python3-venv  You may need to use sudo with that command.  After installing the python3-venv package, recreate your virtual environment.  Failing command: ['/var/www/djangogirls/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']   vagrant@vagrant:/var/www/djangogirls$ sudo apt-get install python3-venv Reading package lists... Done Building dependency tree        Reading state information... Done python3-venv is already the newest version (3.5.1-3). The following packages were automatically installed and are no longer required:   javascript-common libjs-jquery libjs-sphinxdoc libjs-underscore python-pbr python-pkg-resources   python-six python-stevedore python3-virtualenv virtualenv virtualenv-clone Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 108 not upgraded.  vagrant@vagrant:/var/www/djangogirls$ python3 -m ensurepip ensurepip is disabled in Debian/Ubuntu for the system python.  Python modules for the system python are usually handled by dpkg and apt-get.      apt-get install python-&lt;module name&gt;  Install the python-pip package to use pip itself.  Using pip together with the system python might have unexpected results for any system installed module, so use it on your own risk, or make sure to only use it in virtual environments.   vagrant@vagrant:/var/www/djangogirls$ rm -r myvenv/   vagrant@vagrant:/var/www/djangogirls$ python3 -m venv myvenv The virtual environment was not created successfully because ensurepip is not available.  On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.      apt-get install python3-venv  You may need to use sudo with that command.  After installing the python3-venv package, recreate your virtual environment.  Failing command: ['/var/www/djangogirls/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']   As you can see, I am trying to make a myvenv, which cannot be created due to the python3-venv missing. I have already installed this, but the ensure pip is missing. After searching it seems that the system (Ubuntu 16.04) discourages the usage of the package. Could someone help me work around this problem?
82132
Is there something similar to the Python utility ?  Basically it allows you to install Python packages into a sandboxed environment, so easy_install django doesn't go in your system-wide site-packages directory, it would go in the virtualenv-created directory.  For example:  $ virtualenv test New python executable in test/bin/python Installing setuptools...cd .........done. $ cd test/ $ source bin/activate (test)$ easy_install tvnamer Searching for tvnamer Best match: tvnamer 0.5.1 Processing tvnamer-0.5.1-py2.5.egg Adding tvnamer 0.5.1 to easy-install.pth file Installing tvnamer script to /Users/dbr/test/bin  Using /Library/Python/2.5/site-packages/tvnamer-0.5.1-py2.5.egg Processing dependencies for tvnamer Finished processing dependencies for tvnamer (test)$ which tvnamer  /Users/dbr/test/bin/tvnamer   Is there something like this for RubyGems?