installing python3.3.3 on virtual environment - django

I was using ubuntu 13.04. So python 2.7 is already installed in my system.I need to install python 3.3.3 on my system for a new project.There existed virtual environment in my system.the versions of virtual envs are
virtualenv==1.10.1
virtualenv-clone==0.2.4
virtualenvwrapper==4.1.1
distribute==0.6.49
which is installed on my /usr/local/bin path.So now I need to install python 3.3.3 on my existing environment created with these virtual envs using distribute.Is it possible to install python 3.3.3 with these versions of virtual env or whether I need to upgrade the environments? Please help me.I need the whole steps in installation procedure.
Is this code satisfied virtualenv --python=python3.3 test --distribute python 3.3
Also tell me the best version of django to be used with python 3.3 version

Tested it on my local machine - it does work.
Since Python3 support was added with django 1.5 I recommend it and everything above.
...Django 1.5 is also the first release with Python 3 support!...

Related

Cannot install "psycopg2" on Windows 10 with Python 3.8

Yesterday I uninstalled python 3.7 version by mistake. Then I install python again (this time 3.8 version) and again set up my environment. But I could not start my Django project which has Postgres connection. Actually I cannot install "psycopg2" in my environment. I searched for hours and implement every solutions I get from online but it does not work. Let me tell you what I did so far.
First it said to add Postgres in my PATH so I added C:\Program Files\PostgreSQL\12\bin\ in my PATH.
A new problem then arise with a huge ERROR report with 2 vital Error.
ERROR: Failed building wheel for psycopg2
..........................
Running setup.py install for psycopg2 ... error
I try to upgrade wheel but it says,
Requirement already up-to-date
http://initd.org/psycopg/docs/install.html#install-from-source
I learned from this site that psycopg2 requires python2 version. So I installed python 2.7 also.
I reinstalled PostgreSQL but it does not work.
I deleted my virtual environment and create again but it does not work.
Some says they solve this problem by running pip install psycopg2-binary But it does not work for me.
Please help me to get rid of this. I stuck for hours.
When you asked this question, Python 3.8 had been released very recently so there were not any wheels for Python 3.8 yet.
At the time, my suggestion was to install Python 3.7.X and install the binary wheel with:
pip install psycopg2-binary
Since then, binary wheels have been released for Python 3.8, so the above command should work with Python 3.8.X as well.
I wouldn't try to build from source on Windows if it can be avoided.
Finally, you misunderstood the section of the docs about Python 2. You only need Python 2.7 if you are running Python 2. For Python 3, which you should be using for all new projects, it currently supports Python 3.4 to 3.8.
use:
sudo apt install python3-dev libpq-dev
then try doing:
pip3 install psycopg2
Hope it works for you!!
This problem mainly occurs due to this -- " error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/"
Now to install psycopg2, first you need to install visual studio from Microsoft - https://visualstudio.microsoft.com/visual-cpp-build-tools/
now you need to install the c++ desktop development tool with all its default components selected.
After successful visual studio c++ desktop development kit installation, you can now install psycopg2 successfully in your machine.

Moving django project to Github removes its dependency packages

So I'm working on a blog right now with Django and Python. I created a virtual environment and created my project there. I activated my virtual environment every time, so that whenever I do pip install Django or whatever it installs those packages to my virtual environment. However, When I uploaded my project with virtual env to GitHub and downloaded it on my laptop, and do "pip list" only 4 Django packages(pip, pytz, setuptools, virtualenv) are there. They are all different versions from the original too. My original virtual env has these packages below:
certifi 2018.11.29
chardet 3.0.4
Django 2.1.5
django-embed-video 1.2.0
idna 2.8
pip 18.1
pytz 2018.7
requests 2.21.0
setuptools 40.6.3
urllib3 1.24.1
wheel 0.32.3
Can anyone explain to me what is going on?
When you setup your python project with virtualenv, it install your third party packages on your local machine. That means whenever you copy or clone your repo from github to other machine you have to install all the packages again to run.
To know more about virtulenv please refer to this awesome tutorial.
If you want to build your django project machine independent then I guess Docker is your best bet.

Changing default Python from 2.7.10 to 3.5.2 in terminal so I can install pip

I was hoping for some help in setting up a Python development environment on a Mac.
Background: I'm running a newly upgraded macOS Sierra 10.12.1, and setting up various parts of Python development on it. This macOS version already came with Python 2.7.10 installed - and I'd prefer to leave that alone for now.
So I installed Homebrew, and then used that in turn to install the latest python3, that is, Python 3.5.2; but I guess it's not the default for Terminal yet, since when I run the python -V command, I get this in the Terminal window:
Python 2.7.10
So now I've got at least 2 version of Python on my Mac, and that's fine I guess, but the latest Python one is not the one that is the 'default'. How do I set 3.5.2 as my default rather than 2.7.10?
(Backstory for why I want to do that... pip is not installed, i.e., when I go to Terminal and type in pip, it says:
-bash: pip: command not found
When I tried to follow the installation instructions for pip, I ran into a permissions issue, which makes sense I guess, since I don't have access to the Mac's 2.7.10 Python install, nor do I really want it at this stage. So I'd like to switch Terminal to take the new Python 3.5.2 as my default one, in which case I guess I won't have pip permissions issues...)
Thanks in advance for any help folks!
The safest solution is to create a virtual environment running python 3 and use it as development environment. Check the following links:
https://docs.python.org/3/library/venv.html
http://docs.python-guide.org/en/latest/dev/virtualenvs/

two versions of django installed in ubuntu 16.04

I have two versions installed in my envirment, django 1.8.7 and 1.10 which i have installed with pip! I want to use django 1.10 by default instead of the version 1.8.7. how can I do that ?
thank you
A good way to run multiple versions of Python programs is to use virtualenv.
Installation depends on your operating system, but there is more info here.
See this tutorial for information on how to use virtualenv with Django.
With virtualenvs, you can run multiple versions of Django that use multiple versions of Python. If you add virtualenvwrapper, you can use a simple command, like workon project1 to work on a Django 1.8 project that uses Python 2.7, or workon project2 to work on a Django 1.10 project that uses Python 3.5.
Edit: in 2020 you can do:
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install django
You can install any version of Django there that you want. That version of Django will be different than any version that might be on your system.
Read more about it here: https://docs.python.org/3/library/venv.html

How to get Django to use an updated python on Mac OS X server?

I am using Django on my Mac OS X server. Things are fine, so far. I have been using python 2.6.1 and all works well. I upgraded Python to version 2.7.3. Invoking python in the terminal brings up version 2.7.3, as expected. Checking Django using the {% debug %) reveals that Django is still using the original python 2.6.1 interpreter.
On this system, /usr/local/bin contains a symlink to ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python
In /usr/bin I find the python interpreter, and from that directory, invoking ./python gets python 2.6.1 running.
My $PATH is
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin:/usr/local/bin
which I believe must have been altered on the python 2.7.3 install.
What is considered the optimal way to get the command line and Django using the same Python? I am considering either moving the framework version to /usr/bin and sitting a symlink in the framework to the moved new version. On the system is also a /Library/Python directory, that contains the site-packages for versions 2.3, 2.5, and 2.6. In /Library/Python/2.6/site-packages are the major goodies django, mercurial, and south.
Where are people putting things, nowadays? I mean, I know I could move things around, but I would like to anticipate where the Django project is going so future upgrades can go smoothly.
Install it against the updated Python.
Consider putting your app within a virtualenv container and specifying the version of Python when you create it - as per: Use different Python version with virtualenv