Mmm, ok. I followed your tip and I modified my myapp.wsgi (but I also add 
my site-packages of my virtualenv).

I discovered that my mod_wsgi is compiled for Python 2.7 and not for Python 
3.4... I installed mod_wsgi from apt. Then, I compile my version of 
mod_wsgi for my Apache and my Python3.4 and now they all work.

Sorry and thanks a lot for your patience and for your work.

Il giorno martedì 21 ottobre 2014 22:54:44 UTC+2, Graham Dumpleton ha 
scritto:
>
>
> On 22/10/2014, at 7:15 AM, Claudio Pastorini <pastorin...@gmail.com 
> <javascript:>> wrote:
>
> Mmm, I don't know, I tried to follow TipsAndTricks <http://tipsandtricks/> 
> but 
> it didn't work..
>
> No, I never found them XD, very good lectures, now my virtualenvs works 
> properly, but nothing to do for *lxml* instead..
>
> #!/usr/bin/python3.4
> import sys, os, logging, site
>
>
> ALLDIRS = ['/opt/virtualenvs/myappenv/lib/python3.4/site-packages']
>
>
> # Remember original sys.path.
> prev_sys_path = list(sys.path)
>
>
> # Add each new site-packages directory.
> for directory in ALLDIRS:
>         site.addsitedir(directory)
>
>
> # Reorder sys.path so new directories at the front.
> new_sys_path = []
> for item in list(sys.path):
>         if item not in prev_sys_path:
>                 new_sys_path.append(item)
>                 sys.path.remove(item)
> sys.path[:0] = new_sys_path
>
>
> logging.basicConfig(stream=sys.stderr)
> sys.path.insert(0,'/var/www/myapp/')
>
>
> from myapp import app as application
>
>
> If you were following the blog posts, then the script above need only be:
>
>     import sys
>
>     logging.basicConfig(stream=sys.stderr)
>     sys.path.insert(0,'/var/www/myapp/')
>
>     from myapp import app as application
>
> That is, you can drop all the sys.path fix ups if the Apache configuration 
> is done correctly.
>
> The '#!' line is also not needed in a WSGI script file.
>
> There may be further issues.
>
> The first is whether your mod_wsgi is even compiled for Python 3.4.
>
> This is important as mod_wsgi is compiled for a specific Python version 
> and you cannot force it to use a Python virtual environment for a different 
> Python version.
>
> You can check what Python version mod_wsgi is using by following:
>
> * 
> http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use
> * 
> http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
>
> Check whether that is the case.
>
> Otherwise you are going to have to be more specific about what the current 
> problem with lxml is if there is one. That is, error messages in browser 
> and Apache error logs.
>
> Graham 
>
>
> Il giorno martedì 21 ottobre 2014 03:36:25 UTC+2, Graham Dumpleton ha 
> scritto:
>>
>> What version of mod_wsgi are you using?
>>
>> Have you so happened to have found and read:
>>
>>     
>> http://blog.dscpl.com.au/2014/09/using-python-virtual-environments-with.html
>>     
>> http://blog.dscpl.com.au/2014/09/python-module-search-path-and-modwsgi.html
>>
>> Graham
>>
>> On 20/10/2014, at 11:56 PM, Claudio Pastorini <pastorin...@gmail.com> 
>> wrote:
>>
>> Hi all, I create a simple *Flask app* that use *lxml* in order to parse 
>> html page and I want to use it in my VPS.
>>
>> I don't understand how to use *virtualenv* with mod_wsgi. I found a lot 
>> of different mode in order to do that, but the only one that works for me 
>> is to modify the /etc/apache2/mods-available/wsgi.conf *adding this line*
>>  WSGIPythonPath 
>> /opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/.
>>
>> *(I believe that it isn't the best way because I suppose that in this way 
>> I add this python path in all my app and it isn't a good approach for 
>> future release)*
>>
>> I tried with a *simple Flask app* that print "Hello world" and it *works*
>> .
>>
>> *Then I installed lxml* and other modules in my virtual env *and I 
>> upload my final app* and it *doesn't work*.. The error in apache log is:
>>
>> [...] ImportError: cannot import name etree
>>
>> *I searched a lot on the web and here but I found only that lxml doesn't 
>> work because it uses Cython and wsgi run only a Python interpreter or 
>> something similar.*
>>
>> How can I fix?
>>
>> Sorry for my English. It is my first question on my first experience with 
>> Apache2, mod_wsgi and Flask.
>>
>> I use *Python3.4* and the latest version of *Apache2, mod_wsgi, Flask*
>>  and *lxml*. They run on *Ubuntu Server 14.04*.
>>
>> My configurations are:
>>
>>    - */etc/apache2/sites-available/myapp.conf*:
>>
>> <VirtualHost *:80>
>>                 ServerName myip
>>                 ServerAdmin ad...@mywebsite.com
>>                 WSGIScriptAlias / /var/www/myapp/myapp.wsgi
>>                 <Directory /var/www/myapp/myapp/>
>>                         Order allow,deny
>>                         Allow from all
>>                         WSGIApplicationGroup %{GLOBAL}
>>                 </Directory>
>>                 Alias /static /var/www/myapp/myapp/static
>>                 <Directory /var/www/myapp/myapp/static/>
>>                         Order allow,deny
>>                         Allow from all
>>                 </Directory>
>>                 ErrorLog /var/www/myapp/error.log
>>                 LogLevel warn
>>                 CustomLog /var/www/myapp/access.log combined
>> </VirtualHost>
>>
>>
>>
>>
>>    - */var/www/myapp/myapp.wsgi*:  
>>    
>>
>> #!/usr/bin/python3.4
>>
>> import sys, os, logging, site
>>
>> ALLDIRS = ['/opt/virtualenvs/myappenv/local/lib/site-packages']
>>
>> # Remember original sys.path.
>> prev_sys_path = list(sys.path)
>>
>> # Add each new site-packages directory.
>> for directory in ALLDIRS:
>>   site.addsitedir(directory)
>>
>> # Reorder sys.path so new directories at the front.
>> new_sys_path = []
>> for item in list(sys.path):
>>     if item not in prev_sys_path:
>>         new_sys_path.append(item)
>>         sys.path.remove(item)
>> sys.path[:0] = new_sys_path
>>
>> logging.basicConfig(stream=sys.stderr)
>> sys.path.insert(0,'/var/www/myapp/')
>>
>> from myapp app as application
>>
>> (Dosn't work work?)
>>
>>
>>    - */etc/apache2/mods-available/wsgi.conf*:
>>    
>> WSGIPythonPath 
>> /opt/virtualenvs/myappsenv/lib/python3.4/site-packages/:/var/www/myapp/
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to modwsgi+u...@googlegroups.com.
>> To post to this group, send email to mod...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/modwsgi.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to modwsgi+u...@googlegroups.com <javascript:>.
> To post to this group, send email to mod...@googlegroups.com <javascript:>
> .
> Visit this group at http://groups.google.com/group/modwsgi.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to modwsgi+unsubscr...@googlegroups.com.
To post to this group, send email to modwsgi@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to