python path for setting Django app - python

Believe me or not but after searching the web for half an hour I couldn't find the answer:
How to install django app (ex. django-profile) to the specific python path?
The problem is I installed it with pip but it was installed on the "global" path. I don't want it. I want it to be installed in /home/usr/Dev/lib folder where my project lives.
Could you help me? Am I missing something?
Thank you!

From the author of pip himself:
Install a Python package into a different directory using pip?
PREFIX_PATH=/path/to/folder
pip install --install-option="--prefix=$PREFIX_PATH" django-profile
This would install django-profile in /path/to/folder/lib/pythonX/site-packages

With virtualenv you can customize where the django apps and python packages are installed.

Related

No module named 'captcha.fields'

Hi~I have got a ModuleNotFoundError saying "No module named 'captcha.fields'" when I run manage.py in my Django project.
I confirm that django-simple-captcha has been installed and successfully imported into my programme. But I check the captcha package and I haven't found any definition for captcha.fields.
Could anyone help me, please? Thank you.
pip install django-recaptcha
use this to install package in your python environment
Simply uninstall the package from your virtual environment and reinstall it. Do migrate if need be. The issue should be solved.

Local development of Google App Engine not importing built-in library

I followed the quickstart then I simply clone hello_world from here. I already downloaded google_appengine sdk from here. I extract it and now I have folder google_appengine alongside with hello_world
so I execute it like this:
It runs well apparently, until I start to request to localhost:8080.
then I got this error:
what's wrong with it? did I miss something?
google said that I can use the built-in library without manually install it with pip.
PS: it works when I just deploy it to my project on Google. and also it works if I manually install webapp2 inside lib inside hello_world like described here then request it locally.
my python version Python 2.7.6 on ubuntu 14.04 32bit
Please if anybody can solve this I would be appreciate it.
Seems like this is acknowledged bug in app engine SDK. As a temporary workaround, you may try this steps:
Uninstalling the following PIP packages resolved this issue for me.
sudo pip uninstall gcloud
sudo pip uninstall googleapis-common-protos
sudo pip uninstall protobuf
Credit to this thread:
https://groups.google.com/forum/?hl=nl#!topic/google-appengine/LucknWk8iaQ
Be sure to use correct executable of pip if you use virtualenv or have multiple python versions installed.
Thanks to #Dmytro Sadovnychyi for the answer. It doesn't work for me to uninstall those packages because I never installed it before, But that makes me think maybe built-in library conflict with other package so I decide to create Virtual Environment. just fresh environment no need to install any package.
activate the environment then execute dev_appserver.py hello_world now it works
for now I'll stick with it until next update like said here

Python-Jira installation without Admin rights

I am writing a python tool that should get information from Jira. I wanted to use Python-Jira but cannot install it properly. I am using (have to use) python 2.7 which doesn't come with pip and I cannot install pip because I do not have local admin rights (and won't get them without hassle).
Is there a way to install/use python-jira without the pip installation process? I tried copying the jira package to the site-packages folder but it seems I run into dependency problems ('ImportError: No module named six.moves' when I try import Jira from jira) which to resolve it seems I have to follow the pip installation process.
Thanks for your help.
Install Virtualenv and you will have your own version of Python and Pip, so you should be able to install jira-python properly.
There is a lot of guides how to do it.
For Linux I recommend this one.
General Python Guide

how to install virtualenv and/or pip

Someone please tell me I'm not crazy, becuase I really feel like I am right now.
Ok so, I'm trying to setup a webapp with python and django using heroku, but I've hit quite an odd obstacle.
It wants me to setup a virtualenv using the command $ virtualenv venv --distribute, which is all well and good except:
yeh, so naturally I googled how to install virtualenv and I found this:
But, of course:
So I continued my search by trying to find out how to install pip and I found this:
Aaaaaaand that's when I completely lost my marbles because apparently you need to install pip to install virtualenv to install pip. (maybe not, but that's why I'm a noob and I need help).
But then I took another look at the vitualenv installation guide, and found that I could download it and install it manually, so I extracted all the files from the downloaded archive into my python33 folder and used setup.py install. And I got this:
So I changed the line in that file to except ValueError as e and I got another error from a different python file in that same folder so I reverted the change I made and decided that it probably was not a good idea to meddle with those scripts.
Please, any help at all to do with setting up a free server with python and django would be greatly appreciated. Furthermore, I am sorry if my question is stupid, or incorrectly tagged.
You are following install guides for linux. You should try to find an install guide for pip and virtualenv on windows. First install pip systemwide and then use pip to install virtualenv systemwide. Then start using virtual environments.
Start with How to install pip on W$ and Python and virtualenv on W$. An alternative is the Hitchhiker's guide to python.
Edit
As Ron Elliott states in the comments,
you'll need to point your path to C:\Python2x\Scripts or C:\Python3x\Scripts in order to pick
up easy_install and pip as well as any other script executables
installing to that directory.
But then I took another look at the vitualenv installation guide, and
found that I could download it and install it manually, so I extracted
all the files from the downloaded archive into my python33 folder and
used setup.py install.
You downloaded the package and run setup.py install in wrong folder, that's why it didn't work.
You should:
Download the archive virtualenv-1.10.tar.gz to a Downloads folder (or where ever you want)
Extract it, you will have a folder name virtualenv-1.10
Go to (cd) the extracted folder
Run command: python setup.py install
Anyway I would recommend installing setuptools and pip first, then you can install virtualenv from pip: pip install virtualenv.

importError: no module named _winreg python3

Where can I download _winreg for python3 if I can at all. I have my 'windir' on E:\Windows. I do not know if cx_Freeze did not notice that. I am using cx_Freeze to create an msi installer.
As it says in the _winreg documentation, it has been renamed to winreg in Python 3.0. You should run the 2to3 tool if you're converting code that was written for Python 2.x.
I know this is an old question, but this was the first search result when Googling for ModuleNotFoundError: No module named '_winreg', and perhaps may be helpful for someone.
I got the same error when trying to use a virtual environment folder, which has been created using different (already deleted) python binaries. The solution was recreate the virtual environment:
Delete the virtual environment folder
Run python -m venv <name_of_virtual_environment>
I have found an easy solution for this, Even though i found it after a lot of Rnd, the solution implementation is so simple and straight forward. Hope it can help many people with the same problem.
If you dont have the latest version of Python installed on your machine, You need to download it from (https://www.python.org/downloads/) and then click on Add to path option and just finish the installer.
Please open CMD and move to the python latest version directory, then run the pip install package name (e.g) pip install pygame and it will be successful
1. C:\WINDOWS\system32>cd C:\Users\admin\AppData\Local\Programs\Python\Python37-32
2. C:\Users\admin\AppData\Local\Programs\Python\Python37-32>pip install Pygame
It will install the packages now without any issues.
Downloading
Successfully installed Pygame-1.9.4
C:\Users\admin\AppData\Local\Programs\Python\Python37-32>
If you are still facing issues in Pycharm after trying the above solution, please try the following steps too.
Create new virtual Environment from settings menu and select the latest version of python framework as Project Interpreter and give a new folder path.
select the pip package you want to import. Recompile the code and the error will clear.
Hope this helps.
When you encounter an error like module of simpleai not found,
use
pip install simpleai
in the prompt and then execute. It will get installed.

Categories

Resources