Change path of pip and pip3 - python

I want to create a user path to install packages installed by pip or pip3 for python 3.7.2, for that, I noticed that C:\Users\VVK\AppData\Roaming\Python\Python37\site-packages by py -m site --user-site and,
I wish to update it by C:\Users\VVK\AppData\Roaming\Python37\Scripts, How is this possible?
I am using Microsoft Windows 10 64-bit.

Python37\site-packages is used to install libraries while Python37\Scripts is used to install programs. The latter should not be used for package installation. Packages when installed should install their programs (executable scripts) into Python37\Scripts themselves.

Related

Install Python module easygui on Ubuntu 16.04 without Pip or setup.py

I am new to Ubuntu coming from Windows. I need to install the easygui Python module but the version currently on PyPI has issues. The previous release 0.97 is fine. Using pip install easygui installs 0.98. I can download the 0.97 library from SourceForge and I want to install it on Ubuntu 16.04. The download does not have a setup.py file (which I get how to use to install libraries). In Windows I could copy the easygui.py file to the Libs directory and call the module. Where do I put this file in Linux 16.04? The file structure is confusing for me.
You can use pip to specify the version of the module you would like to install:
pip install easygui==0.97
You could also tack on the flag --force-reinstall if you run into trouble with the module being installed already.
as a side note: This might be a good time to start using virtual environments.
If you have easy_install working, you could try:
"sudo easy_install easygui"
or if you want to specify the location or if you do not have the root privileges:
"easy_install --install-dir=here-some-folder-where-to-install easygui"
If you want to install some specific version of the tool with the easygui, perhaps this post helps:
Install particular version with easy_install
At least "sudo easy_install easygui==0.97" worked for me.

How to setup pip for coexisting Python 2.7/3.4?

I am using Anaconda Python 3.4 on a Windows 7 PC now. Recently I am trying to follow the instruction of the book High Performance Python to learn some profiling skills. To this end I need to use pip install to install several tools. Unfortunately, not all of them support Python 3, and I have to install Python 2.7 now.
Before installing Python 2.7, I would like to know how I should handle with such 2.7/3.4 coexisting system? How do I setup pip so that I could use pip install to install packages for different Python versions separately?
You can create a conda environment via:
conda create --name py27 python=2.7
and use this environment for your work with Python 2.7. Activate it with the command activate py27, going back to your root environment is just activate.
In the py27 environment you can install pip and all other packages you need.
pip is generally located at the Python27\Scripts and/or Python34\Scripts folder. If you wish to invoke pip directly in the command line, these folders should be in your PATH environment variable.
Now I would just rename pip.exe in Python34\Scripts into any other name, for example pip_for_3.exe. That way, when I install packages for Python27, I would just use:
pip install <package name>
and packages for Python34:
pip_for_3 install <package name>
Coexisting Python installations are not a problem, you just have to know which version is invoked every time. See this answer for the same idea.

Python packages -- system and user's have different versions

if I have sudo pip install a python package to a system-wide location
and I pip install --user a different python package to my user location
What would python use when I do import packagename? How do I control the version? or python always uses the most updated one?

Install python module for non-default version on linux

I have different python versions installed on my ubuntu machine. The default version is 2.7.
So when I install any new python module, for example using:
#apt-get install python-nfqueue
it will be istalled just for the default version (2.7)
How can I install the new modules for the other versions?
Is there a way to do it using apt-get install?
Thank you!
You should install Python libraries with the Python package installer, pip.
Create a virtualenv with the Python version you want to use, activate it, and do pip install NetfilterQueue. You'll still need to install the system dependencies (eg libnetfilter-queue-dev in this case) with apt-get.
You can install pip to work with different versions of python. Here is a link to the pip read the docs page(http://pip.readthedocs.org/en/latest/installing.html).
to install pip to the default version of python on your machine:
python get-pip.py
to install for non standard versions call python with the version you wish to install for:
python33 get-pip.py
you can then run pip for python version 3.3 by calling
pip33 install pythonmodule

Python - No pip when creating a virtual environment

So I heard about the proper way to install packages into python by creating a new virtual environment for every project. Being on a mac (10.8) I have installed python3 using Homebrew, then I installed pip and virtualenv on this copy.
Now here comes the problem:
I create a new virtualenv, and activate it using:
virtualenv testing
source testing/bin/activate
When I type
which python
/Users/mik/Desktop/testing/bin/python
But typing
which pip
/usr/local/bin/pip
(learned of this when trying to install a package in the virtual environment, and it installed in the system wide installation in /usr/local/)
Inside the folder testing there is no file referring to pip
Extra Question: How does pip know which python to install the files to, for example pip list (which I believe refers to python 2.7) outputs the names of packages installed on python 3.3
I'll start with the last question as it explains what is happening.
The commands pip and easy_install are python scripts which are made executable on the filesystem. The python they use is the python that the first line tells to run the script. e.g. in /usr/bin/easy_install it is #!/usr/bin/python This will be Apple's python. So easy_install will install the 2.7 version of pip and virtualenv and will ignore your python3.3 setup.
The way to instal into python 3 is to install the 3.3 version of pip and virtualenv, the easiest way would be to install the Homebrew package for them. I think it is easier and less confusing to use just one package manager (Homebrew here) and not two (i.e. Homebrew and python).
You can also install easy_install directly. The way to do this is install the distribute package using python3.3 explicitly.
Python 3.4 will make this much easier as pip will always be available

Categories

Resources