How to install webpy framework on Windows - python

I have python 3.3.2 installed on windows 8 x64.
I am trying to install webpy framework. What I tried:
Downloaded latest webpy.
Extracted to python directroy.
in command promp I cd {python_dir/webpy_sub_dir}, then
python setup.py install
I get this error:
Traceback ....
File "setup.py", line 6 ....
from web import __version__
File ........ /web/__init__.py, line 14 in <module>
import utils,db,net,wcgi,http,webapi, .........
ImportError: No module named 'utils'
What could be the problem? I could not find any tutorials relating to windows installs.
P.S. I realise this is borderline "not a programming question" but looking at other stack forums there isn't a better place for this(IMO).

You might need to download the utils package from pypi
https://pypi.python.org/pypi/python-utils/

In the end the problem was that webpy is not compatible with python 3.x. I went with a similar alternative - bottle py.

Web.py is been ported to python 3.
You can join mail list and help

Related

Cannot install custom python module

I am having trouble installing a custom python module I have written.
Here are my steps so far:
Navigate to the module directory C:\Users\myname\repos\mymodulename where the setup.py file is in the anaconda prompt. Type: python setup.py install
The command prompt returns (plus some other things)
Extracting mymodulename-0.1-py3.7.egg to c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
mymodulename 0.1 is already the active version in easy-install.pth
Installing myclass-script.py script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installing myclass.exe script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installed c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages\mymodulename-0.1-py3.7.egg
Processing dependencies for mymodulename==0.1
...
Using c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
Finished processing dependencies for mymodulename==0.1
To me that looks like it has installed. Opening up the console and trying to import:
>>> import mymodulename.myclassas ce
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mymodulename'
>>>
It appears in hasn't. Checking the list of modules in anaconda with help('modules') confirms that it has not been imported.
I thought that perhaps i had installed it to the wrong environment:
(base) C:\Users\myname>conda env list
# conda environments:
#
base * C:\Users\myname\AppData\Local\Continuum\anaconda3
py2 C:\Users\myname\AppData\Local\Continuum\anaconda3\envs\py2
Only a python 2 environment which mymodule wouldn't be compatible with.
Does anyone have any suggestions about what I can try to resolve this? Happy to elaborate on any of the points
Thanks in advance.
EDIT: Some more information that may be relevant.
This package was initially installed in site-packages. I have reinstalled there and the package works. The reason I moved the package is because I am aware it is bad practice to store custom packages there.

Problems with Python: ImportError: No module named ... [Linux]

I am a noob with installing python programs. I know there are a lot of Questions like this here, I have tried to find a solution for my problem but I can't fix it.
First of all, I am trying to install a program called Qarq. The readme says:
Setup
In order to get qark running, it must be present on your python path. If not, it may lead to module not found errors. This can be done for your current shell by running the following:
export PYTHONPATH={qark root directory}:$PYTHONPATH
Well, I type the command. I check the variable with an echo and I can see the directory in the variable. However, I type "python setup.py install" and I get this error:
santoku#santoku-PC:~/qark$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
Then, I read in a question here that you must install setuptools, so I did it. I ran the next command:
sudo apt-get install python-setuptools
But the problem is still there, I try to run "python setup.py install" and I get the same error.
On the other hand, the readme says you only need to execute "$ python qarkMain.py". I do that and I get the same error with different module:
santoku#santoku-PC:~/qark/qark$ python qarkMain.py install
Traceback (most recent call last):
File "qarkMain.py", line 30, in <module>
from qark.modules.IssueType import IssueSeverity
ImportError: No module named qark.modules.IssueType
I am using Python 2.7.12 (default, Nov 12 2016, 01:02:22) [GCC 4.8.4] on linux2. (Ubuntu 14.04.5 LTS)
I have tried to install qark on Ubuntu 16.04.1 LTS and it worked perfectly. I didn't need to install setuptools. Both have the same python version.
I guess the problem is python can't find the modules, maybe I have to move the qark directory to another directory.
I think that's all, if you need more extra information just ask me.
I need your help, I am sure my problem is a foolishness and easy to fix. But I am a noob with python and I don't have any idea.
Thank you very much and thanks in advance.
Sorry for my English, I am not a native speaker.
EDIT: I found a solution, I tried to install again the OS and now python works properly, I don't know if I broke python or I did something bad. Anyway, Thanks.
i could get it work typing this:
1) PYTHONPATH=\home\santoku\qark\qark\:$PYTHONPATH
then just type:
2) python qarkMain.py

Error Installation Google Cloud SDK

While following the installation steps for "Mac OS X" Installation and Quick Start
I used the below command:-
curl https://sdk.cloud.google.com | bash
and directory extract under /Users/xxxxx/google-cloud-sdk/
but I got this error:-
Traceback (most recent call last):
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
import bootstrapping
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
import setup
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/setup.py", line 44, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/core/util/platforms.py", line 6, in <module>
import platform
ImportError: No module named platform
Environment:-
Mac OS X Yosemite 10.10
Python 2.7.6
$ whereis python /usr/bin/python
Can someone help?
I have found different locations of standard modules, for example:-
>>> import platform >>> platform.__file__ => '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform‌​.pyc'
>>> import os >>> os.__file__ => somewhere inside my profile /Users/xxxxx/Library/Frameworks/Python.framework/... ,
So, I have solved this issue by following steps:-
removed /Users/xxxxx/Library/Frameworks/Python.framework/.
reinstalled python through brew to keep Apple python away.
then, Google Cloud SDK was installed smoothly and is working properly.
and the new location of standard modules is /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
I can't comment since i don't have enough rep, so posting as an "answer".
As others have commented, platform is a standard module. It should be there barring a bad python installation.
Since the python in PATH seems to import platform correctly, maybe Cloud SDK is using a different python.
Check if the environment variable CLOUDSDK_PYTHON is set. That usually tells gcloud to use a different python.
You can also change /Users/xxxxx/google-cloud-sdk/bin/gcloud and right before the last line, echo the bash variables $CLOUDSDK_PYTHON, $CLOUDSDK_PYTHON_ARGS, $CLOUDSDK_ROOT_DIR, and $PYTHONPATH. This should tell us if something is configured badly with the python that gcloud uses.
on linux i fixed this by running install.py directly .you can apply the same on mac os i guess,
go to the folder where you have extracted google cloud sdk then,
cd /bin/bootstrapping
there you will find install.py ,run it using
./install.py
then installation begins and proceed with the steps .After that open a new terminal gcloud works!
Had a similar issue with a different system package (contextlib), solved it by setting the environment parameter: CLOUDSDK_PYTHON_SITEPACKAGES=1 before installing.

Virtualenv issue with flask-werkzeug

I have installed virtualenv along with flask, werkzeug, jinja2 and SQLAlchemy. I was following the tutorial mentioned on the flask website and i came across the below error when executing flask code
Traceback (most recent call last):
File "hello.py", line 1, in ?
from flask import Flask
File "/root/myproject/env/lib/python2.4/site-packages/Flask-0.7dev_20110211-py2.4.egg/flask/__init__.py", line 18
from .app import Flask, Request, Response
^
What i feel is that virtualenv contains python 2.4 and in the documentation of flask it is mentioned that flask supports python 2.5. So maybe that might be the problem or it might be someother issue. Please help me out on this.
Secondly i would like to know the process of getting the latest virtualenv which has Python 2.7 or any tips on how to install it on virtualenv.
I am using CentOS
Thank You in Advance
The import .module syntax is introduced in Python 2.5 (relative import). So you have to use at least 2.5 for this thing.
dunno what you did and how old your virtualenv is .. but you make your own virtualenv by:
% python -c "import urllib, os; os.mkdir('py-env'); \
urllib.urlretrieve('http://goo.gl/D2RB', 'py-env/virtualenv.py')"
% python py-env/virtualenv.py --no-site-packages py-env
% source py-env/bin/activate
% pip install flask SQLAlchemy
that should work. virtualenv itself does not 'contain python'. do you run the correct version of python (dunno whats installed on your distro)?
There are a couple of posts below which should help:
http://cols-code-snippets.blogspot.com/2011/02/start-new-python-project-with.html
http://cols-code-snippets.blogspot.com/2011/02/my-take-on-flask-application-skeleton.html
So can we clarify what is meant when they say "virtualenv itself has no python" take a look in the corresponding bin/ or /lib directories when a env is created or what about the fact one can supply the -p flag when creating a virtualenv -p python2.7. So do as fear_matrix did, install the required python and then create a virtualenv with it "virtualenv -p python2.7". Maybe this is different on centos but I wouldn't think so.

How should I handle software packages?

I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. My platform: CentOS release 5.3 (Final). I have Python-2.6.2.
I also found out that I need .rpm files. As far as I have them I execute:
rpm -i sqlite3-devel-3.n.n.n.rpm
and everything should be fine.
However, I do not know where to find sqlite3-devel-3.n.n.n.rpm file. Should it already be on my system? I could not locate it with "locate sqlite3-devel-3". Should I download this file? If yes where I can find it and which version should I use? I mean, the .rpm file should be, probably, consistent with the version of sqlite that I have on my computer? If it is the case, how can I find out the version of my sqlite?
If I type "from pysqlite2 import dbapi2 as sqlite" I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pysqlite2
"yum search pysqlite" gives me the following:
Loaded plugins: fastestmirror
Excluding Packages in global exclude
list Finished
==== Matched: pysqlite ==== python-sqlite.x86_64 : Python bindings
for sqlite.
By the way, I have the following directory:
/home/myname/opt/lib/python2.6/sqlite3
and there I have the following files:
dbapi2.py dbapi2.pyc dbapi2.pyo
dump.py dump.pyc dump.pyo
__init__.py __init__.pyc __init__.pyo test
If I type "import unittest" and then "import sqlite3 as sqlite" I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myname/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import * File "/home/myname/opt/lib/python2.6/sqlite3/dbapi2.py",
line 27, in <module>
from _sqlite3 import * ImportError: No module named _sqlite3
Thank you in advance.
Python 2.6 (and some earlier) include sqlite Python org library ref so you should not need to do this. Just import it and run
You can use buildout to create localized version of your project. This will install all necessary packages without having sudo access to the server.
To give it try, do the following:
mkdir tmp
cd tmp
wget http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py
python bootstrap.py init
vim buildout.cfg
edit buildout.cfg and replace it with following:
[buildout]
parts = sqlite
[sqlite]
recipe = zc.recipe.egg
eggs = pysqlite
interpreter = mypython
Now, run ./bin/buildout to rebuild the project. This will download all of the necessary packages and create a new interpreter for you that you can use test that you can access sqlite.
./bin/buildout
./bin/mypython
>>> import sqlite3
This gives you a controlled environment that you can use to develop inside of.
To learn more about buildout, you can watch videos from pycon 2009 on Setuptools, Distutils and Buildout.
Eggs and Buildout Deployment in Python - Part 1
Eggs and Buildout Deployment in Python - Part 2
Eggs and Buildout Deployment in Python - Part 3
Good luck
Typically, you should install the python sqlite module through yum, something like:
yum install python-sqlite
and then edit your code changing sqlite2 references to sqlite3.
By the way, whenever you read directions to install sqlite3-devel-3.n.n.n.rpm, the n parts are not literal; they're supposed to be replaced with numbers specifying a version of the rpm package.

Categories

Resources