w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

install python module custom location, PYTHONUSERBASE / virtualenv
First of all, you need to add C:mysite to your PYTHONPATH. Then, when installing a new module, you do: PYTHONPATH=C:mysite python setup.py install --install-lib C:mysite Source: http://wiki.alwaysdata.com/wiki/Installing_a_Python_module

Categories : Python

working in python console while executing a boost::python module
You have two options: start python with the -i flag, that will cause to drop it to the interactive interperter instead of exiting from the main thread start an interactive session manually: import code code.interact() The second option is particularily useful if you want to run the interactive session in it's own thread, as some libraries (like PyQt/PySide) don't like it when they arn't started from the main thread: from code import interact from threading import Thread Thread(target=interact, kwargs={'local': globals()}).start() ... # start some mainloop which will block the main thread Passing local=globals() to interact is necessary so that you have access to the scope of the module, otherwise the interpreter session would only have access to the content of the thread's scope.

Categories : Python

Install python module to non default version of python using .sh
You should run your scripts in a virtualenv created for your app's environment. This creates an isolated environment that uses the Python interpreter you created the virtualenv with, but with its own set of libraries. # create the virtualenv folder: M2Crypto-venv python2.7 virtualenv.py --distribute M2Crypto-venv # activate the virtualenv, changing environment variables to use its Python interpreter . M2Crypto-venv/bin/activate # see how the current python has changed which python # should be M2Crypto-venv/bin/python python --version # should be 2.7 # after activating, run your install scripts If you're using mod_wsgi or something similar to serve content, you'll want to modify your WSGI file to activate the virtualenv before doing anything else (adapted from mod_wsgi instr

Categories : Python

How to Install Matplotlib Basemap Module on Windows 7 with WinPython (or any Python stack install)?
I use windows. And my installation failed with official guidance, too. Finally I installed Basemap using the following method. Although I am not sure if it will go right for you, I just offer mine. First of all, you must have pip in your computer. (It is much easier to install, compared with Basemap and other things. And it can be used to install many useful packages.) Then go this great link: http://www.lfd.uci.edu/~gohlke/pythonlibs/ And download the file named "basemap‑1.0.8‑cp27‑none‑win_amd64.whl". Remove the .whl file to directory "C:Python27". (Maybe you installed your python in different disk, then change it accordingly.) Open terminal. (Use cmd or Git Bash or something else.) Use command: pip install basemap‑1.0.8‑cp27‑none‑win_amd64.whl

Categories : Python

cannot import module using boost.python
Boost python requires the boost python so file. You can add it to your path when you run the python in a variety of ways. I am using export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH:../ThirdParty/boost_1_52_0/lib/linux64/

Categories : C++

Undefined symbol in Boost.Python module
$man nm ... "U" The symbol is undefined. What does that mean? It's not there. Try ldd on your so . This will tell you all the libraries it uses. You then need to make sure all the libraries are on LD_LIBRARY_PATH

Categories : C++

import classes from pyside inside of a boost python module?
PySide provides its Qt bindings with Shiboken. Shiboken generates Python C API bindings that supporting its own type conversion system. The knowledge of these conversions resides within the Shiboken generated bindings, and not the Python type system. Thus, PySide knows how to convert a QPointF object to/from C++/Python; Python's type system does not. When an object transitions through a function exposed with Boost.Python, then Boost.Python will check its registry for the appropriate type converter. These converters provide Boost.Python with knowledge on how to convert to/from C++/Python for types exposed through Boost.Python. Hence, when Boost.Python tries to return a QPointF C++ type to Python, it throws an exception as the conversion has not been registered with Boost.Python. Here

Categories : C++

Cannot install PySpotify module for python due to gcc failed
src/module.c:3:28: error: libspotify/api.h: No such file or directory is the source of your problems. Just having the DLL is not enough, the header needs to be available as well. https://github.com/mopidy/pyspotify/issues/63 covers a similar issue and might provide some hints on how to fix this for Windows.

Categories : Python

How to install and import python module in the same script?
It will not work with setuptools, because setuptools will install pexpect as an egg, and then add it to easy-install.pth, which is checked only on startup. You can get around this in various ways, but it's easier to instead use pip to install pexpect: >>> import pexpect Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named pexpect >>> import os >>> os.system('bin/pip install pexpect') Downloading/unpacking pexpect Downloading pexpect-2.4.tar.gz (113kB): 113kB downloaded Running setup.py egg_info for package pexpect Installing collected packages: pexpect Running setup.py install for pexpect Successfully installed pexpect Cleaning up... 0 >>> import pexpect >>> pip will install

Categories : Python

Exposing boost::gregorian::date to Python using Boost.Python
After some research I found the answer. You can supply static functions to .def as well. Just give it to_iso_extended_string and it gets the object as first argument. BOOST_PYTHON_MODULE(mymodule) { class_<boost::gregorian::date>("Date") .add_property("year", &boost::gregorian::date::year) .add_property("month", &boost::gregorian::date::month) .def("__str__", &to_iso_extended_string) ; }

Categories : Misc

python 2.7.5 failed to build module when install the gentoo prefix
Try this: mv $EPREFIX/tmp/usr/lib/libpython2.7.a $EPREFIX/tmp/usr/lib/_libpython2.7.a as mentioned from the following link: http://forums.gentoo.org/viewtopic-t-890016-start-0.html Also look at this post for resolving some of the modules if the above doesn't work: http://www.kelvinwong.ca/tag/python-2-7/

Categories : Linux

How can one locally install an extension to an existing system python module?
With a change to the basemap package (submitted here https://github.com/matplotlib/basemap/pull/154) I could import the out-of-system-wide mpl_toolkits.basemap in a way like this: (this was quickly made, some of the stuff is probably not necessary) mybasemap.py in the basemap mpl_toolkits dir (might need to change those): from mpl_toolkits import * import mpl_toolkits import sys sys.path.insert (0, './mpl_toolkits/') sys.path.insert (1, './') from basemap import Basemap then do: from mybasemap import Basemap in the final script (after adding the path to mybasemap.py).

Categories : Python

Dot-slash not recognized in command prompt - Trying to install Python module
try to do configure if you are in the directory where that file is located. If you aren't in the same folder do this C:usersmynamepath ameconfigure If it isn't an exe, change the filetype and windows will run it

Categories : Python

boost-python: How do I provide a custom constructor wrapper function?
Use no_init followed by a .def for __init__ using boost::python::make_constructor(). class WrapperFuncs { public: static boost::shared_ptr<CppClass> initWrapper( object const & p ) { SpecialParameters sp = ... // do complicated extraction here. return boost::shared_ptr<CppClass>( new CppClass(sp) ); } static void doSomething(CppClass & c, tuple t) { /*...*/ } }; class_<CppClass, boost::shared_ptr<CppClass> > ("CppClass", no_init) .def("__init__", make_constructor(&WrapperFuncs::initWrapper)) .def("doSomething", &WrapperFuncs::doSomething, (arg("t"))) This section of the python wiki explains how to do this, but it didn't quite work for me because it didn't mention no_init. In my case, no_init was requi

Categories : C++

Python installing PyQt4 module to custom software
That binary version of PyQt4 only supports python2.7, so no matter what you do, you won't get it to run with python2.5. The last PyQt4 version with a binary for python2.5 is PyQt4.9.4, so if you want to have any chance of making this work you should try with this version. Note however that the software you distribute like this will also only run on python2.5.

Categories : Python

Boost::python - filling a C++ vector of pointer on object of a class in python
Actually, I found a solution to my issue. By filling the vector (including calling setAderivediList) directly in setAListPy. I just pass an int my_A_derived to setAListPy (actually, along with other arg required by all A_derived class constructors) and use a if condition on my_A_derived.

Categories : C++

Exposing a C-style array data member to Python via Boost.Python
As you've seen, Boost.Python unfortunately doesn't provide automatic converters for C arrays, and even the STL container wrappers it provides aren't how I'd recommend approaching this (at least if your real problem is similar to your example one in terms of how large the array is, and if you know you want to expose it as a true Python tuple). I'd recommend writing a function that converts the C array into a Python tuple, using either the Python C-API directly, or its boost::python wrappers, and then exposing the data member via a property. While you could avoid data copying by using a NumPy array instead of a tuple, for small arrays that's not worth the effort. For example: namespace bp = boost::python; bp::tuple wrap_arr(S const * s) { bp::list a; for (int i = 0; i < 10; +

Categories : C++

build error while exposing classes to python using boost.python
I have found the solution to this issue and it works like this: std::string getName() { //return this->get_override("getName")(); return boost::python::call<std::string>(this->get_override("getName")()); } However, according to the boost python documentation this has to be used only for MSVC6/7, which is not my case since I am using VS2010 (MSVC 10.0).

Categories : C++

boost.python Avoid registering inner class twice but still expose in python
Turns out it is quite straightforward once you know how as is the usual case with boost.python. In python this worked: IC.DoubleOuter.Inner = IC.IntOuter.Inner but wasn't the solution I was looking for. In C++ this works: scope outer_scope( outer_class ); outer_scope.attr( "Inner" ) = handle<>( inner_registration->m_class_object ); which I had already tried but hadn't realised that I needed to wrap the class object in a handle<>.

Categories : Misc

boost::python passing reference of python::list
In short, Boost.Python maintains Python argument passing semantics with its TypeWrappers. Thus, when passing a list in Python to an exposed C++ function, a reference can be created and maintained by accepting the Python list as a boost::python::list object. The detailed answer actually has a bit more depth to it. Before delving into it, let me expand upon some semantics to avoid confusion. With Python's garbage collection and pass-by-object semantics, the general rule of thumb is to treat the Boost.Python TypeWrappers as smart pointers. If the function accepts the list as a boost::python::list object, then C++ now has a reference to the Python object. The Python list's lifetime will be extended to be at least as long as the booot::python::list object. If the Python list is conver

Categories : C++

Importing dependent python libraries from boost python
If B.so links against A.so, then A.so needs to be in a path used by the dynamic linker when B.so is loaded. For example, before importing module B, add the path containing A.so to the LD_LIBRARY_PATH environment variable. There is a distinction between a library and a module. A.so is a library, not a module. When attempting to import a module, Python may eventually try to load a library, requiring the library to initialize a module. In this case, library A.so initializes module A when it is loaded by the Python interpreter. The documentation for sys.path states that it specifies the search path for modules. Hence, import B will find B.so as part of the import and sys.path behavior. However, when the dynamic linker loads B.so, the dynamic linker, not the Python interpreter, requires

Categories : C++

Get a c++ pointer to a Python instance using Boost::Python
The recommended way is to query into the namespace in which the entity object was created, then store a handle to the entity object as a boost::python::object. When interacting with Python objects from C++, it is best to use boost::python::object whenever possible, as it provides a high-level notation that acts much like a Python variable. Additionally, it provides the appropriate reference counting to manage the lifetime of the Python object. For example, storing a raw pointer (i.e. pointerToPythonObj* ) would not extend the life of the Python object; if the Python object was garbage collected from within the interpreter, then pointerToPythonObj would be a dangling pointer. Here is an example demonstrating this: Entity.py: class Entity: def action(self): print "in Enti

Categories : C++

Pass pointer from C++ to Python /w boost python?
It turns out this was a bug in the interaction between Mingw-w64 and Python. I performed the procedure described here and the problem was solved: http://ascend4.org/Setting_up_a_MinGW-w64_build_environment#Setup_Python_for_compilation_of_extensions

Categories : C++

preventing addition of system Python path to virtualenv easy-install.pth by python setup.py develop
When you do python setup.py develop That ^ python that you are using to run setup.py is not necessarily associated with the virtual environment. You need to ensure that you are running the virtualenv's version of python by navigating directly to python.exe in your virtual environment and using that to run setup.py. Alternatively you can just call activate.bat in your scripts folder and it will do it all for you, ensuring that nothing outside of the virtual environment is used. edit if you are certain that you are using the virtualenv's python.exe please ensure that when you created the virtual env you used the --no-site-packages flag virtualenv --no-site-packages myEnv edit2 the --no-site-packages seems to have been OP's problem

Categories : Python

Install OpenCV for Python (multiple python versions)
Use virtualenv virtualenv -p python2.7 env source env/bin/activate python --version # prints «Python 2.7.3» pip install pyopencv If you need support of 2.4 (or other version), just create new environment.

Categories : Python

Programatically install Python msi application from a Python script
Normally every well designed MSI can be installed silently. The given standard command line should be tried out, other optional parameters maybe TARGETDIR for the directory etc. The msiexec parameters "/quiet" and "/qn" do the same, don't use them both. The main problem in your case is about admin rights. A script normally does not run with admin rights, if you have not done special things (like adding/changing manual manifests). If you just use the parameter "/qb" instead of "/qn" normally MSI should come up with UAC. Try it out first, it's the easiest (maybe not the absolutely best) solution. Not silent, but unattended installation, may be sufficient for you. Or even "/qb+" then you get a final box too. To start an installation (or everything else requiring admin rights) from a script

Categories : Python

python ast module fails in pydev, succeeds in cmdline python
It seems the ast you have imported in PyDev is not the ast module in the standard library, but a package. I guess: There is a __init__.py file in the same directory as your test1.py. You selected "Add project directory to the PYTHONPATH" during the project creation. These two combined, results in that error. The ast module in the standard library is shadowed by this ast package. In cmdline python, this ast package is not in the search path, thus the ast module is imported. If you change test1.py to import ast if __name__ == '__main__': print ast.__file__ I guess the output in PyDev would be C: esearchastast\__init__.pyc

Categories : Python

Is there a way to import an embedded python script into IronPython as a python module?
It is possible. You just need to add search paths to ScriptEngine object like this: var paths = engine.GetSearchPaths(); paths.Add(yourLibsPath); // add directory to search or engine.SetSearchPaths(paths); Then you could use any module in directories, which you add: import pyFileName # without extension .py Update OK. If you want to use embedded resource strings like module, you may use this code: var scope = engine.CreateScope(); // Create ScriptScope to use it like a module engine.Execute("import clr " + "clr.AddReference("System.Windows.Forms") " + "import System.Windows.Forms " + "def Hello(): " + " System.Windows.Forms.MessageBox.Show("Hello World!")", scope); // Execute code from string in scope. Now you ha

Categories : C#

How can I run a python program in Komodo IDE like in IDLE(Python GUI) using Run Module feature?
Is Python on your PATH? That is, if you open a command prompt and type python by itself, does it run? In Komodo, look under Edit/Preferences/Languages/Python3 and check the configuration. If python.exe is not on your PATH you can provide the full path to it there

Categories : Python

How can I specify the version of Python that Perl's Inline::Python module is using?
You link with desired version during the installation of the module. See Makefile.PL: #============================================================================ # What python are we going to try? #============================================================================ my @pythons; my $sep = $^O eq 'MSWin32' ? ";" : ":"; for $p (split /$sep/, $ENV{PATH}) { $p =~ s/^~/$ENV{HOME}/; $p .= "/python"; push @pythons, { path => $p } if -f $p && -x $p; } # Keep them in PATH order. #@pythons = sort { $a->{path} cmp $b->{path} } @pythons; my $num = 1; print "Found these python executables on your PATH: "; print $num++ . ". " . $_->{path} . " " for @pythons; my $sel = prompt("Use which?", '1'); $sel = $pythons[$sel-1] if $sel =~ /^d+$/; $sel = { path => $

Categories : Python

How do I install a package with npm with a different/custom module name
One way would be to put it in your package json file and then run npm install... Something like this "dependencies": { "public": "git://github.com/user/repo.git#ref", "private": "git+ssh://git@github.com:user/repo.git#ref" } Source:http://www.devthought.com/2012/02/17/npm-tricks/

Categories : Node Js

module works for /usr/bin/python but not /opt/local/bin/python
Was having this issue myself this week. The solution with thanks to [1] is to build it yourself from the git sources [2]. git clone https://github.com/Kitware/VTK.git VTK mkdir VTK-build && cd VTK-build ccmake ../VTK Press 't' for advanced mode. Ensure you've set "VTK_WRAP_PYTHON: ON". Press 'c' to run the first configure. Set PYTHON_EXECUTABLE: /to/your/python (for Macports: /opt/local/bin/python) Set PYTHON_INCLUDE_DIR: /to/your/Python.framework/Headers (for Macports: /opt/local/Library/Frameworks/Python.framework/Headers) Set PYTHON_LIBRARY: /to/your/Python.framework/libpythonx.x.dylib (for Macports: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib) Press 'c' to run final configure Press 'g' to generate make files make [sudo] make install

Categories : Python

Can I bring a Python 2.6 module (fractions) to Python 2.5?
Use the source! Just download the source and modify it as needed for 2.5 I also some this: http://answers.yahoo.com/question/index?qid=20090610101000AAerKHj Or you could use SymPy: Pure Python rational numbers module for 2.5

Categories : Python

Pip install python package into a specific directory other than the default install location
System: Ubuntu 12.04, Enthought Python Distribution (this is where I wanted to install a new python module) So the prefix_path environment variable didn't work for me and pip still kept installing it in the default location. But I used change default directory for pip install question as a guide. And one of the answers helped me achieve what I needed. pip install -d <path_to_my_directory> For the path I used: path_to_epd_directory/lib/python2.7/site-packages This puts the tar.gz file into the site-packages Then extract it using: tar -zxvf pymodule.tar.gz a directory named pymodule is created, cd into that module and type: python setup.py install and that should do the job.

Categories : Python

Do I need to create a module for: A user account, to create and save custom "objects" made of choices from a form
Drupal is great for such a project. And you don't need too much extra modules, just core modules. 1) Core user module is fine. 2) Node type A. Create the node with the described fields and a user Role that will be able to add new A nodes as also as edit/delete own A nodes. 4) Node type B. Just add relationship for the Node type A so users can make the connection. Use the EntityReference module here. Similar user role permissions here. 6) This needs more information but it seems you need to use Views module to achieve this. 7) Welcome to Drupal! This is a core functionality also.

Categories : Forms

Import python module over the internet/multiple protocols or dynamically create module
In principle, yes, but all of the tools built-in which kinda support this go through the filesystem. To do this, you're going to have to load the source from wherever, compile it with compile, and exec it with the __dict__ of a new module. See below. I have left the actually grabbing text from the internet, and parsing uris etc as an exercise for the reader (for beginners: I suggest using requests) In pep 302 terms, this would be the implementation behind a loader.load_module function (the parameters are different). See that document for details on how to integrate this with the import statement. import imp modulesource = 'a=1;b=2' #load from internet or wherever def makemodule(modulesource,sourcestr='http://some/url/or/whatever',modname=None): #if loading from the internet, you'd

Categories : Python

why is python argparse giving the help for imported module rather than current module?
Your tone module defines an argument parser at the module level and prints the help message as it parses your command line arguments If you only want the parsing to take place if tone is being run as a script, move the parser.parse_args() call to your __main__ test block: if __name__ == '__main__': # run as a script, not imported as a module args = parser.parse_args()

Categories : Python

python c api not able to import any module into the newly created module
Resolved this in a different way : The problem is that the __dict__ attribute of a module is read-only. I am using the python/c api for 2.7.5. After using PyModule_New there was no provisioning to execute any code into the __dict__ for imports in the api. So I used a different approach. I created a module using python code rather than the python/c api. Which has the provision to to execute some code into a modules dictionary exec 'import sys' in mymod.__dict__. The sys import provides the newly created module to have access to sys.modules which has all the available modules. So when I do another import, the program knows where to look up the path for the import. Here is the code. PyRun_SimpleString("import types,sys"); //create the new module in python PyRun_SimpleString("mymod = t

Categories : Python

Trying to install a Scitools Python pkg via 'pip install' but getting error
I had the same error but resolved it by manually installing all the Anaconda packages. NumPy SciPy Pandas PyTables h5py Matplotlib IPython Spyder Qt/PySide VTK Numexpr Astropy Cython LLVM LLVMpy Numba Scikit-learn Scikit-image NLTK NetworkX MayaVi

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.