Unable to install a specific version of django on virtualenv - python

I have been trying to install django 1.8 on virtualenv, i performed the following steps:
changed to my project directory
changed to scripts folder of virtual environment which I created
activated the virtual env
typed command: pip install django == 1.8
Nothing worked
also, tried pip install django and easy_install django, however, none worked.
Could you please help me out ?

Can you try this command:
sudo pip install django==1.8

One problem could be that the command line doesn't tokenize the command correctly. Try the following (with the quotes around the requirement specifier):
pip install "django==1.8"

Like you haven't shared the output error, I suggest some actions:
Try to use the absolute path or add the path of your pip installation to your PATH system variable:
Go to CMD change the python instalation directory C:\>cd \Python27\Scripts and type C:\Python27\Scripts>pip -h
If works well you can use the absolute path C:\Python27\Scripts>pip install "django==1.8" or add the path of your pip installation to your PATH variable using the command above:
C:\Python27\Scripts>setx PATH "%PATH%;C:\Python27\Scripts"
SUCCESS: Specified value was saved.
Another attempt is updating pip scripts using easy_install
(FlaskEnv27) E:\Projects\FlaskEnv27\Scripts>easy_install pip
Searching for pip
Best match: pip 1.5.6
Removing pip 1.3.1 from easy-install.pth file
Adding pip 1.5.6 to easy-install.pth file
Installing pip-script.py script to E:\Projects\FlaskEnv27\Scripts
Installing pip.exe script to E:\Projects\FlaskEnv27\Scripts
Installing pip.exe.manifest script to E:\Projects\FlaskEnv27\Scripts
Installing pip3.4-script.py script to E:\Projects\FlaskEnv27\Scripts
Installing pip3.4.exe script to E:\Projects\FlaskEnv27\Scripts
Installing pip3.4.exe.manifest script to E:\Projects\FlaskEnv27\Scripts
Installing pip3-script.py script to E:\Projects\FlaskEnv27\Scripts
Installing pip3.exe script to E:\Projects\FlaskEnv27\Scripts
Installing pip3.exe.manifest script to E:\Projects\FlaskEnv27\Scripts
Using c:\python27\lib\site-packages
Processing dependencies for pip
Finished processing dependencies for pip

Related

Python on anaconda cannot find azure.mgmt.datafactory

I am trying to run this tutorial
https://learn.microsoft.com/en-US/azure/data-factory/quickstart-create-data-factory-python
but I fail to install the packages. I tried several installations but I keep getting the error No module named 'azure.mgmt.datafactory' when trying to run from azure.mgmt.datafactory import DataFactoryManagementClient.
I am using anaconda and windows 10.
I tried running the recommended anaconda packages https://anaconda.org/anaconda/azure and https://anaconda.org/clinicalgraphics/azure-mgmt-resource under a python 3.5 environment and I also tried to manually install everything from github (https://github.com/Azure/azure-sdk-for-python) using
git clone git://github.com/Azure/azure-sdk-for-python.git
cd azure-sdk-for-python
python setup.py install
In both the normal (Python 3.6) and the new (Python 3.5, using Anaconda version with Python 3.5) environment. None of this worked.
What am I missing?
(Note that from azure.mgmt.resource import ResourceManagementClient worked fine with the anaconda installation)
EDIT
After the first response, I ran the following commands from the powershell
pip install azure-mgmt-resource
pip install azure-mgmt-datafactory
pip install azure-mgmt
which resulted in ModuleNotFoundError: No module named 'azure.mgmt'
Uninstalling the three packages and installing azure-mgmt as a first one did not solve the issue either. However, I don't know how to uninstall the manually installed package from python setup.py install, which still might be an issue.
Have you tried pip install in powershell/cmd?
pip install azure-mgmt-datafactory
Update (Jan's answer):
pip freeze > requirements.txt
pip uninstall -r requirements.txt
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory (this might not be needed as it comes with azure-mgmt)
Ok, this is how I got the required azure libraries to work (thx to Saul Cruy, who gave me the idea)
Using this post What is the easiest way to remove all packages installed by pip?, I created a requirements file in PowerShell
pip freeze > requirements.txt
In this file, I manually kept only the entries with azure.
Then, I deleted all packages in the file
pip uninstall -r requirements.txt
The steps above were repeated twice, as upon first delete, some azure packages survived.
Then, I ran (all in PowerShell, in that order)
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory
The reason might(!) be that installing packages in the anaconda console using the conda commands causes confusion in the dependencies (I tried a similar approach in a conda environment as it seemed like a good idea to seperate the azure packages from the other ones, but without success).

pip installing to wrong folder even though `which pip` is correct

I'm using Mac OS X 10.10. I want to use pip to install packages for my homebrew installed version of python (located in /usr/local/bin/python, which is an alias that points to /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin). It appears that site-packages for this version are here: /usr/local/lib/python2.7/site-packages/.
which python returns /usr/local/bin/python
which pip returns /usr/local/bin/pip
These seem correct to me.
Trying something like pip install pylzma returns:
Collecting pylzma
Installing collected packages: pylzma
Successfully installed pylzma
You are using pip version 8.0.2, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But then pip list does not show pylzma to be installed. It looks like pip installs the packages to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (the python that ships with Mac OS X).
How can I get pip to install to my homebrewed python?
I've tried a number of suggestions from similar questions:
I've tried export PATH=/usr/local/bin/python:${PATH}.
I've tried pip install --install-option="--prefix=/usr/local/lib/python2.7" pylzma.
I've tried changing the first line of the pip executable script to #!/usr/local/bin/python
I've tried /usr/local/bin/python -m pip install pylzma.
But none of these work. I also tried upgrading pip to 8.1.1, but that made pip break entirely. People recommend using virtualenv, but as far as I know, I can't install that without pip.
When I type python -m pip, it says:
Usage:
/usr/local/opt/python/bin/python2.7 -m pip <command> [options]
Could that be a problem?
My issue was that my /Users/<username>/.pydistutils.cfg contained the following:
[easy_install]
# set the default location to install packages
install_dir = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
[install]
install_lib = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
install_scripts = ~/bin
I changed this to:
[easy_install]
# set the default location to install packages
install_dir = /usr/local/lib/python2.7/site-packages
[install]
install_lib = /usr/local/lib/python2.7/site-packages
install_scripts = ~/bin
That seemed to have worked. pip install now installs packages to the desired location /usr/local/lib/python2.7/site-packages.
However, I am have ongoing path issues.
import pylzma still gives me ImportError: No module named pylzma.
and running jupyter notebook in terminal gives -bash: jupyter: command not found. /Users/<username>/bin/jupyter notebook does execute, but I get ImportError: No module named markupsafe despite the fact that /usr/local/lib/python2.7/site-packages/MarkupSafe-0.23.dist-info exists.
EDIT: I got jupyter notebook working eventually. I had to install several packages from the source tarballs directly, including MarkupSafe, functools32, and jsonschema. Maybe Python is not looking in the correct folder or something.

Installing requests-kerberos on Windows

Is there any way to install requests-kerberos on Windows?
When I try to install it with pip I have the following error:
py -m pip install requests-kerberos
ImportError: No module named 'commands'
Command "python setup.py egg_info" failed with error code 1 in C:\Users\user1\AppData\Local\Temp\pip-build-n8s_inn\kerberos
I would be grateful if anyone knew another kerberos module. I'm using Python 3.4 and Windows 8.
Best regards.
The commands module was deprecated in python 2.6.
Thus, the issue appears to be a problem with your pip installation, and not with requests-kerberos.
There are a few things you can try, but I would focus on ensuring pip is working correctly. While you could install the package manually, you are really just pushing the pip problem down the road until the next time you install a package.
Ensure pip is installed correctly.
Use the pip command to ensure you are running pip in the python 3.4 context: (Note, this is my output, yours will be different because you are on Windows and running 3.4)
$ pip --version
pip 1.5.6 from /Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg (python 2.7)
Additional information about pip can be found here.
Download and install manually
Download the package manually from the pypi repo.
Download the .tar.gz
Extract the tar.gz and run python setup.py install

how to install setuptools in mac

I'm trying to install via pip some libraries but I'm having some problems.
When I try to install some of them I require for my project I get this message:
$ sudo pip install dj-database-url==0.2.0
Downloading/unpacking dj-database-url==0.2.0
Downloading dj-database-url-0.2.0.tar.gz
Cleaning up...
setuptools must be installed to install from a source distribution
It also happens when trying to install distribute==0.6.24
Any ideas?
Download ez_setup.py module from https://pypi.python.org/pypi/setuptools
Open a Terminal.
cd to the directory where you put the ez_setup.py.
Type python ez_setup.py and run it.
You should have it then.
After a pip install command I was getting the same error as you ("setuptools must be installed to install from a source distribution"). Since I couldn't find a solution, it was a lot faster to reinstall the virtual environment where python was running from.
If you're using virtualenvwrapper this is very easy. First you remove your problematic virtual environment (let's say it is called "venv") with:
rmvirtualenv venv
Then you setup a new one with the same name:
mkvirtualenv venv
And finally you install all your packages, including the one you had problems with:
pip install dj-database-url

Can pip copy dependency source into my virtualenv?

I am a bloody beginner in Python and Django. To set up a environment on my Windows machine, I performed the following steps.
Install Python 3.4
Use pip to install virtualenv
Create a project folder and set up a virtualenv there
Download Django 1.7b1 release from the official site
Extract the archive in my downloads folder
Install it into my virtualenv
For the last step, I used pip from my virtualenv.
[project]\scripts\pip.exe install -e [downloads]\Django-1.7b1
From the global python interpreter I can't import django, as expected. When using the python executable from the virtualenv, it works. But the import only succeeds as long as I have the Django source in my downloads folder. Instead, I would like to include it into my virtualenv.
Can I make pip to automatically copy the Django source into my project folder?
Install django via pip inside the virtualenv. I'm running Linux but you should be able to run the commands on windows.
If you need a version that's not in PyPi, download the package and install it to the virtualenv site-packages-folder.
My site-packages folder for project is in ~/venvs/project/lib/python2.7/site-packages.
To install there:
pip install downloads/Django-1.7b1.tar.gz -t ~/venvs/project/lib/python2.7/site-packages
Django will install to the site-packages folder and is now importable from within the virtualenv. Downloads/Django-1.7b1 is no longer needed.
Below is an example where I'm installing Django 1.7b1 from a local archive to the site-packages-folder of my virtualenv:
(project)msvalkon#Lunkwill:/tmp$ pip install /tmp/Django-1.7b1.tar.gz -t ~/venvs/project/lib/python2.7/site-packages/
Unpacking ./Django-1.7b1.tar.gz
Running setup.py egg_info for package from file:///tmp/Django-1.7b1.tar.gz
-- SNIP --
Successfully installed Django
Cleaning up...
(project)msvalkon#Lunkwill:/tmp$ python -c "import django;print django.get_version()"
1.7b1
(project)msvalkon#Lunkwill:/tmp$ deactivate
# I've got a really old version installed globally, but you can see
# that the installation worked.
msvalkon#Lunkwill:/tmp$ python -c "import django;print django.get_version()"
1.5.1
After this you should find the following output when doing pip freeze while the virtualenv
is activated:
(project)msvalkon#Lunkwill:/tmp$ pip freeze
Django==1.7b1
argparse==1.2.1
wsgiref==0.1.2

Categories

Resources