PYTHONPATH and PATH system variables - python

I am working with quantum gis 1.7.2.During installation it creates python25 folder.
I am working with python2.6 for python plugins for QGIS.
i set system variable as:
PATH :=C:\Program Files\Quantum GIS Wroclaw\apps\qgis
C:\Python26\Lib\site-packages\PyQt4\bin
PYTHONPATH:=C:\Program Files\Quantum GIS Wroclaw\apps\qgis\python;
ErrorMessage
Traceback (most recent call last):
File "C:\rt_sql_layer_working\DlgQueryBuilder.py", line 30, in <module>
from qgis.core import *
ImportError: DLL load failed: The specified module could not be found.
is this because of version mismatch or paths are wrong??

Start the python in python25 folder and at the prompt do
from qgis.core import *
If this is working fine, perhaps there are additional libraries provided with this python25 which are not present in 2.6.
You might need to copy these dll's to your python2.6 installation

Normally you'd just want your PATH to be something like c:\PYTHON26 or c:\PYTHON25 not the one you've specified:
C:\Python26\Lib\site-packages\PyQt4\bin

Related

Installing Mapnik v.3.0.12 on Win 8 with Python 2.7

I've been trying to work on this for hours where I ended up having to download Python 2.7 Version but still no luck.
Following the installation tutorial from Git: Mapnik Windows Installation, most specifically paying attention to Step 3 where PATH and PYTHONPATH variables are instructed to be added.
Both my USER and SYSTEM PATH Variables have the following modification:
FROM ;C:\mapnik-v2.2.0\lib; C:\mapnik-v2.2.0\bin; TO ;C:\mapnik-v3.0.12\lib; C:\mapnik-v3.0.12\bin;
Both my USER and SYSTEM PYTHONPATH:
C:\mapnik-v3.0.12\python\2.7\site-packages;
Additionally ONLY in my SYSTEM PATH Variable, I appended:
C:\Python27\
When I tried to test import mapnik the common problem still occurs:
>>> import mapnik
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mapnik
Again, every solution that I've read said to check my variables. I can't figure out why it won't import properly despite the path modifications.

Python module sqlite3 cannot be found, but is listed [duplicate]

I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?

When I try to import PySTAF i get the following error. I am using a 32bit STAF for 32bit PYTHON

C:\STAF32\bin>python PySTAF.py install
Traceback (most recent call last):
File "PySTAF.py", line 9, in <module>
import PYSTAF
ImportError: DLL load failed: The specified module could not be found.
Environment variable points to C:\STAF32\bin;
Pythonpath = C:\STAF\bin\
Pycharm environment vairble = PYTHONCASEOK=
Stuck on this one for a long time.
You have to manually add the path to the PySTAF module to the system path.
STAF installation doesn't take care of this one automatically.
If you are on windows, create a new Env Variable: PYTHONPATH = "C:\STAF\bin" (location to PySTAF.py module in your installation)

python: ImportError: No module named

I'm beginning to learn python,
but when I try to import modules from an ather file I get this error:
Traceback (most recent call last):
File "./test", line 4, in <module>
from multip import table
ImportError: No module named multip
The both files are in the same directory
when I import modules like 'math' or 'os' it's work, the probleme is between files
OS:ubuntu 12.04
python version:python 3.2.3
You can import only files that have a .py extension. (or directories having a __init__.py file in them).
EDIT : I was not aware that modifying the PYTHONPATH environnement was considered as a bad practice. The reason given by #wRAR is that it has a permanent effect that can have uncontrolled side effects. You had better trying the first proposition (sys.path.append) to see if it can solve your problem. More about the sys.path.append vs PYTHONPATH can be found in this topic : PYTHONPATH vs. sys.path
Isn't it related to your PYTHONPATH environnement variable ? If you add '.' or the directory were you are working, I guess it should be ok
in your shell :
export PYTHONPATH=.:$PYTHONPATH
python test.py
or (for test purpose, not to be used systematically) in your python file :
import sys
sys.path.append(".")

Why my python does not see pysqlite?

I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?

Categories