Hey there i got a problem installing photologue application. Im following installation instructions.
~/coffee$ python manage.py shell
Python 2.6.1 (r261:67515, Mar 18 2009, 13:52:30)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import photologue
>>> photologue.VERSION
(2, 3)
but after adding
'photologue',
to my installed apps, when i try to python manage.py syncdb im getting an error:
Error: No module named photologue,
Whats the reason of that :(
You might have multiple versions of Python and Django is using a different one from the one photologue was installed to.
Or if you're using virtualenvs, you might have installed photologue into the main Python site-packages, that virtualenvs, typically and intentionally, don't have access to.
Related
I have a Python 2.7 question, if somebody can help.
When we install a Python module using pip, how do we make it available to all users? Please, see the example below (with module faker). The import works when I am root, but doesn’t work when I am ubuntu user.
I have already tried to install using option --system, and also changing umask, as recommended in some articles I have found. Didn’t work so far. Any ideas?
If we run "which python", both users point to the same one.
root#ip-172-30-244-157:/home/ubuntu#
root#ip-172-30-244-157:/home/ubuntu# python
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import faker
>>>
>>> exit()
root#ip-172-30-244-157:/home/ubuntu#
root#ip-172-30-244-157:/home/ubuntu#
root#ip-172-30-244-157:/home/ubuntu# exit
exit
ubuntu#ip-172-30-244-157:~$
ubuntu#ip-172-30-244-157:~$
ubuntu#ip-172-30-244-157:~$ python
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import faker
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named faker
>>>
Ok, I solved the issue.
In my case, the problematic module was "faker". But, when we install the faker, another additional module is installed as well (in this case - text-unidecode).
Then I uninstalled both modules, ran "umask 022" and re-installed the faker.
This solved the issue for all other users.
Thanks all for the help!
I'm unable to run nosetests on my tests, because of module import errors.
I am running inside of a virtualenv with global site packages enabled.
I can successfuly run the tests from the IDE (pycharm). I can also import the module directly from cli. I can also (not shown) run a python script tht imports the troublesome module.
I assume this is a path issue, but haven't been able to discover the root cause. I have also toggled no-path-adjustsment in .noserc to no avail.
(ipc)➜ Analytics git:(feature/ipc_via_rest) pip freeze | grep arrow
arrow==0.7.0
(ipc)➜ Analytics git:(feature/ipc_via_rest) python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> arrow.utcnow()
<Arrow [2015-11-30T16:29:57.363278+00:00]>
>>> exit()
(ipc)➜ Analytics git:(feature/ipc_via_rest) nosetests src/bnr_analytics_data_services/
<elided>
ImportError: No module named arrow
Try running nosetest --pdb. It will bring up pdb debugger on error. Look at sys.path for abnormalities.
I'm using the OpenID module as part of a flask application.
I've been looking in the module directory to see which methods are accessible, but was wondering if it's possible to see the code/logic behind the methods themselves. If so, how?
is there a similar command to dir(oid) for this?
You can usually find the source file for any given module by looking at the help output.
For example:
Python 2.7.6 |Anaconda 1.9.1 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import collections
>>> help(collections)
Help on module collections:
NAME
collections
FILE
//anaconda/lib/python2.7/collections.py
...
From here you can open the file and view the source.
You can either have a look at your python installation/virtualenv "lib" folder
For example Flask src can be found at:
(pythondir)\Lib\site-packages\flask
Or online:
flask
flask-openid
I installed 64bit package of cefpython in Ubuntu 12.04 LTS (http://code.google.com/p/cefpython/). The problem is I am not able to run the examples. It says no module named wx.
But when I navigate to the directory /usr/local/lib/python2.7/dist-packages/cefpython1 and do import wx it works. So basically I am not able to import wx outside that directory. I am using python interpreter on terminal.
rishi:cefpython1 ls
cefclient cefpython_py27.pyc chrome.pak examples __init__.pyc LICENSE.txt wx
cefpython_py27.py cefpython_py27.so devtools_resources.pak __init__.py libcef.so locales
rishi:cefpython1 python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>>
[2]+ Stopped python
rishi:cefpython1 cd ..
rishi:dist-packages python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx
>>>
KeyboardInterrupt
>>>
My PATH is as follows and PYTHONPATH is empty:
installed 64bit package of cefpython in Ubuntu 12.04 LTS (http://code.google.com/p/cefpython/). The problem is I am not able to run the examples. It says no module named wx. But when I navigate to the directory /usr/local/lib/python2.7/dist-packages/cefpython1 and do import wx it works. So basically I am not able to import wx outside that directory. I am using python interpreter on terminal.
rishi:dist-packages echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
rishi:dist-packages echo $PYTHONPATH
rishi:dist-packages echo $PYTHONPATH
rishi:dist-packages
Your problem here is that python has no idea where you are importing from. Refer to This post for instructions. Basically, what is happening is that when you're in the directory, python knows to look for it (it looks for python files and packages in the directory). You need to add the python libraries into the PYTHONPATH.
Im unable to start new project in a virtualenv. This is what i did so far: (fresh windows installation)
1) installed python 2.7 from http://python.org/download/ (not the 64 one)
2) using "set path=%path%;C:\python27" only seems to work for one cmd session, so i added C:\Python27; in my environment variables under advanced system settings, typing python in cmd returns
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
3) downloaded virtualenv.py from http://pypi.python.org/pypi/virtualenv/ ran it with:
C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS>python virtualenv.py testenv
New python executable in testenv\Scripts\python.exe
Installing setuptools....................................done.
Installing pip.........................done.
4) activated it and installed some modules
C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts>activate
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts>
...
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS>pip install -r requirements.txt
...
Successfully installed...
5) tested if it works:
testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.4
>>>
6) Tried to setup a project:
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>django-admin.py startproject testproject
Traceback (most recent call last):
File "C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts\django-admin.py"
, line 2, in <module>
from django.core import management
ImportError: No module named django.core
Path from virtualenv:
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['','C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages\\pip-1.1-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\DLLs',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\plat-win',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\lib-tk',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\Scripts',
'C:\\Python27\\Lib',
'C:\\Python27\\DLLs',
'C:\\Python27\\Lib\\lib-tk',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages']
I have no idea whats the problem, and how to fix it, also got another question, are those files from c:\python27 supposed to be in my virtualenv path?
Should i attach any other logs? Poke me if so.
Step 6 is where things start to go wrong
Your windows has bound .py(w) files to use Python from c:\python27 directory, not from your virtualenv.
I've written blog entry about virtualenv and win7:
http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/
I agree with jtiai, things go wrong in step 6 because Windows has bound a specific Python. If you did python path/to/django-admin.py startproject it should work.
Please go through the below given tutorial link..
http://ayarshabeer.com/post/50973941605/install-multiple-django-version-using-virtualenvwrapper
Instead of using virtualenv, on Windows I prefer to use Portable Python : http://www.portablepython.com/. You can have several installations on the same machine and switch between them just by setting the path:
set path=d:\python\app\scripts;d:\python\app;%path%
Moreover, it already contains Django. Once you have set up your python environment, you can copy your python directory over to your production server.