I have installed the Enthought Python Distribution (i.e. python 2.7) on a Ubuntu 12.04 virtual machine and it would be very useful if it could recognise modules imported via the synaptic package manager. Currently, these are only recognised by the system-provided python installation (quite understandably). Since both pythons are 2.7, is it possible to make my EPD installation recognise the system modules? Thanks.
No, using synaptic-installed modules with EPD is not supported. Of course, you can try adding specific packages to your PYTHONPATH, but this is likely to create conflicts, especially for modules containing C-extensions that may be linked against a slightly different version of Python.
Currently, the recommended way to install python packages in EPD is with the enpkg tool. Try enpkg -s <packagename> to see if your desired package is in Enthought's repository. If you haven't already, you should upgrade enpkg itself by running enpkg enstaller and enter your EPD credentials by running enpkg --userpass. Then you should be able to install supported packages with enpkg <packagename> (Using enpkg to update EPD packages).
If the package you're looking for isn't in Enthought's repository, you can install pip with enpkg pip and install packages in EPD with that tool.
Alternately, you can download the source for your desired package and install it with python setup.py install, assuming the package has a setup.py.
Note: if you install a package into EPD without using enpkg, you should make sure to remove the EPD version of the package first if it exists (enpkg --remove <packagename>). If you later choose to install the package with enpkg, you should first remove the version you installed with an alternate method (Using non-EPD package installers such as pip).
There is also an upcoming GUI package manager from Enthought, currently in Beta.
Had the same problem.Enthought distribution uses completely different python paths and library prefix than your run of the mill system distribution. So if you use pip, pip will install on your system path, not your EPD path.
Solution:
1) get your EPD prefix with: enpkg --path
2) write it down somewhere
3) if you pip install then type:
pip install --install-option="--prefix=$PREFIX_PATH" package_name
as written by Ian Bicking on Install a Python package into a different directory using pip?.
The previous answer might be obsolete. On version 4.6.3 use enpkg --env to get the prefix
$ enpkg --version
enstaller version: 4.6.3
$ enpkg --env
Related
I would like to install the newest version of docutils via pip, but it can't figure out how to upgrade the system version installed via apt.
$ sudo --set-home python2 -m pip install --upgrade docutils
Collecting docutils
Using cached https://files.pythonhosted.org/packages/3a/dc/bf2b15d1fa15a6f7a9e77a61b74ecbbae7258558fcda8ffc9a6638a6b327/docutils-0.15.2-py2-none-any.whl
Installing collected packages: docutils
Found existing installation: docutils 0.14
ERROR: Cannot uninstall 'docutils'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
$ apt-cache show python-docutils | head -n 3
Package: python-docutils
Architecture: all
Version: 0.14+dfsg-3
None of the solutions I've thought of or found on the web appeal:
Delete the apt version with rm -rf /usr/lib/python2.7/dist-packages/docutils*. This silences pip but means:
Installed files on the system no longer match what the Debian packaging system thinks
I might break dependencies of system software on docutils 0.14
Any updates to the Debian package will cause apt to reinstall
Other problems discussed in this answer
pip install --force-reinstall. (Same problems.)
pip install --ignore-install. (Same problems.)
Is there a way to get a default environment that works for me with the newest versions of stuff from pip but has no chance of breaking any system software? The same answer above suggests using one of virtualenv, venv, pyenv, pipenv. I tried pipenv and it doesn't want to install individual packages listed on the commandline using --system and I don't know whether creating a Pipfile will actually solve this problem.
I would rather not have to manually switch environments somehow to use the apt-installed packages versus the pip-installed packages. Is there a way to get only apt-installed software to use one environment and otherwise use the environment with the pip-installed stuff?
I would rather not have to manually switch environments somehow to use the apt-installed packages versus the pip-installed packages. Is there a way to get only apt-installed software to use one environment and otherwise use the environment with the pip-installed stuff?
Ideally, one should use either the system version or the pip version.
Per the Debian Python Policy,
As long as you don't install other versions of Python in your path, Debian's Python versions won't be affected by a new version.
If you install a different micro version of the version of Python you have got installed, you will need to be careful to install all the modules you use for that version of Python too.
So far adding the following to ~/.bashrc seems work well:
if [ ! -d ~/venv/python3 ]; then
python3 -m venv --system-site-packages ~/venv/python3
fi
if [ -d ~/venv/python3 ]; then
VIRTUAL_ENV_DISABLE_PROMPT=1 . ~/venv/python3/bin/activate
fi
Most of the system-installed scripts have one of the Pythons in /usr/bin hard-coded instead of using /usr/bin/env python so they are unaffected by this.
I have the following version of python
import sys
print(sys.version)
3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:44:09)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]
I installed a package with the following command
pip install wfdb
It is succesfully installed because when I then write the command:
pip show wfdb
The following information appears
Location:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
However, when I type the command import wfdb in Python notebook or the version of python in terminal, I get the following message
No module named 'wfdb'
Does it have to do with the path on which python is checking where the packages are? How to check this and how to change it?
You have (at least) 2 Python installations, one managed by Anaconda, the other what appears to be an official Python.org Mac build installed system-wide. The pip command on the command-line is the one tied to the Python.org Mac build.
pip is a script that is tied to a specific Python installation, and there can be multiple versions of the script installed in different locations, and is usually also installed with pipX and pipX.Y to match the X.Y version indicator of the Python version it is tied to. For Python 3.6, that means the same script would also be available as pip3 and pip3.6. (This also means that pip can be connected to Python 2 or Python 3, depending on your exact OS setup. It is not a given that pip, without a version number, installs into Python 2.x as some answers may claim).
Note that when you run a command without a path in your shell, (such as pip as opposed to /usr/bin/pip), you are asking your shell to find the command for you in a number of locations, listed in the PATH environment variable. The first location in the PATH list with that command is then fixed. which -a <command> would tell you all possible PATH-registered locations that the command can be found in. You can always use the full path to a command to bypass the PATH search path.
You can always verify what Python version the pip command is connected to with:
pip -V
which will output the version of pip and the location it is installed with. It'll print something like
pip pipX.pipY path/to/pythonX.Y/site-packages/pip (python X.Y)
where pipX.pipY is the pip version number and path/to/pythonX.Y tells you what Python installation this is for.
You can try to match this with the Python version by running
python -m site
which outputs the Python module search path for that Python version. Python can be run with python, pythonX and pythonX.Y too, and is subject to the same PATH search.
Note the -m switch there, that instructs Python to find a module in it's module search path and execute it as a script. Loads of modules support being run that way, including pip. This is important as that helps avoid having to search for a better pip command if you already can start the right Python version.
You have several good options here:
Since you are using Anaconda, you could look for a conda package for the same project. There is such a package for wfdb. Install it with
conda install wfdb
Anaconda aims to give you a wider software management experience that includes a broader set of software options than just the Python PyPI ecosystem, and conda packages usually manage more things than just the Python package.
Conda packages are usually maintained by a different set of developers from the package itself, so there may be a newer version available on PyPI (requiring pip install) than there is on Conda.
This is not an option for all Python packages, if there is no conda package you have to use pip. See Installing non-conda packages.
you can use the conda command to create a conda environment. Once you have an environment created, you can activate it with
source activate <name_of_cenv>
to alter your PATH settings. With the envirnoment 'active' the first directory listed on your PATH is the one for the conda environment and the pip command will be the one tied to that environment.
Note that a conda environment gives you an isolated environment for a specific project, keeping the library installation separate from the rest of your Python packages in the central site-packages location. If you want to install a package for all of your Anaconda Python projects, don't use a conda environment.
Use the Anaconda Python binary to run pip as a module; when you can run /path/to/python or pythoncommand to open the right Python version, you can use that same path to run /path/to/python -m pip ... instead of pip ... to be absolutely certain you are installing into the correct Python version.
Look for a better pip command, with which -a pip or which -a pip3.6, etc. But if you already know the Python binary, look in the same bin location for pip. If you have anaconda/bin/python, then there probably is a anaconda/bin/pip too.
As you can read here:
pip3 and pip would make a difference only when you are not using any
environment managers like virualenv (or) conda. Now as you are
creating a conda environment which has python==3.x, pip would be
equivalent to pip3.
For this reason it could be you did not activate your Conda environment before installing required packages and running your code.
Activate the new environment:
On Windows:
activate myenv
On macOS (this should be your option) and Linux:
source activate myenv
NOTE: Replace myenv with the name of the environment.
which python
gives the you the PATH to python
and then /path/to/python -m pip install thepackagetobeinstalled
Many thanks #MartijnPieters
You have installed python2.x package and you're using python3.x. Try:
pip3 install wfdb
If you don't have pip3 run:
[apt-get/yum] install python3-pip
You can see what packages you have currently installed by running:
pip freeze
and for python 3.x packages
pip3 freeze
Please remember each time you install a Python package, it will be placed in the directory for one particular Python version. Hence your error.
I have a python2.6 installed on Oracle linux.
I decided to use a newer python version and installed python 2.7.13.
I have also installed pip to manage packages.
Now if I use pip to install a package it still installs it to the old location: /usr/lib/python2.6/site-packages
Is there a way to force pip to install packages for the newer python 2.7 version?
Posable Repeat Post
"Use a version of pip installed against the Python instance you want to install new packages to.
In many distributions, there may be separate python2.6-pip and python2.7-pip packages, invoked with binary names such as pip-2.6 and pip-2.7. If pip is not packaged in your distribution for the desired target, you might look for a setuptools or easyinstall package, or use virtualenv (which will always include pip in a generated environment).
pip's website includes installation instructions, if you can't find anything within your distribution." ~Charles Duffy
Taken from How to install a module use pip for specific version of?
Did you check Install a Python package into a different directory using pip?.
To install in specified target directory use "pip install --target= "
Oracle Linux uses the system-installed version of Python for almost all of its command-line utilities, so changing that could irreparably damage your system.
Instead of replacing the default Python install, you should strongly consider using Python 2.7 from Software Collections instead.
Using Software Collections means that the install of Python 2.7 is separated from the system install, so you don't run the risk of damaging your system. You can then make it available to your applications via the scl tool.
I have Python 2.7.11 installed on my machine which to my understanding should come with pip, however when I check the C:\Python27\Tools\Scripts\ directory there is no pip.exe present.
I have tried completely removing and reinstalling Python 2.7.11 without success. Running the installer pip is set to be installed, but after the install pip is nowhere to be found.
I also have Python 3.4 installed which has pip as expected. Any thoughts?
I encountered the same problem - pip not installed - with python-2.7.16, Win10, installing for 'all users'. It was resolved when I allowed the MSI installer to target the default location (C:\Python27) rather than changing it to under Program Files (x86). I've no clue why this changed anything.
python2.7.11 should install pip into c:\python27\scripts, you can take a look here
I used https://pip.pypa.io/en/stable/installing/ to make it install. Odd that an outside body has to make a tool to get pip to install. There is no mention of pip.pypa.io on the Python web site.
Although I got error messages, it did install, so check carefully.
You also may see a message suggesting that you upgrade to pip 9.0 with the command 'pip install --upgrade.' I highly recommend that.
Also, make sure you are in the directory where pip.exe is located when you run the commands. They don't tell you that, because they assume you know that, but we're not all geeks.
For people who are running into this issue, I have a Windows 10 x86 dev box that I use for exploit development, Python 2.7 was installed due to Immunity Debugger, this install did not include the new SSL package and did not include "pip".
There was no "C:\Python27\Scripts" folder which included pip. I did have a "C:\Python27\Tools\Scripts" folder which did not have pip installed.
I tired to install pip as suggested but did not work. Best way is to uninstall Python and install newest version, currently mine is 2.7.15 which came with pip as an option. This is what solved my issue, any older version of Python will need upgraded to support the SSL packages. You will receive the same errors when you try to install pip on an older version.
If you have reinstalled Python which included the SSL package and it still does not have pip, trying installing pip this way:
1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. python get-pip.py
https://pip.pypa.io/en/stable/installing/
This should work if you have a newer version of Python.
Once you have installed pip or newer version of python, go to "C:\Python27\Scripts" and you should see pip.exe.
I have installed "python-2.7.16" in my windows 10 PC. PIP is installed under "C:\Python27\Scripts". One can add the "C:\Python27\Scripts" path to environment variable and then access pip command from command prompt.
To add the path in environment variable:
Control Panel\System and Security\System --> Advanced System Settings --> Advanced --> enviroment variables --> under system variable --> Path(variable name)
Had the issue where no matter which version of python 2.7 I installed on windows 10 there was no pip.exe generated in the "Scripts" folder.
I solved it by ensuring that that MSI Installer file had Admin privileges before installing
if pip is not installed you can use easy_install.exe to install pip and other modules
you can find easy install in
python -m easy_install pip
I had the same issue:
Installed Python 27
Tried to use pip, but failed with unrecognized command error
Checked installation: no "C:\Python27\Scripts", only "C:\Python27\Tools\Scripts"
This issue happens only on some versions of Windows.
HOW TO FIX IT:
Uninstall Python 27
Reinstall Python 27, but unselect "pip" feature
Check installation: no "C:\Python27\Scripts" as expected
Start the installer again and use "Change Python"
Set "pip" and "Add Python.exe to Path" features to be installed
Check installation: "C:\Python27\Scripts" is now correctly present
So for some unknown reason, pip is not correctly installed on some versions of Windows if it is installed during default Python 27 setup. To fix this issue, pip must be installed afterwards using the "Change Python" setup.
I meet the same issue when install Python 2.7.9. The installer does not come with pip.
Solution:
Install newer python2 x86 version: https://www.python.org/downloads/release/python-2718/
Then pip is located at C:\Python27\Scripts\pip.exe
It happens on windows as you should have admin rights to install anything on disk C.
I have the same issue Scripts folder was not installed. I would sugest to instal it on disk D.
I have installed both virtualenv and pywin32 on my Windows 7 64-bit laptop, and each of them seems to work, but not with each other.
More specifically, if a virtualenv is active, then running import win32com.client in a python interactive shell fails with No module named win32com.client. The same expression succeeds, however, if no virtualenv is active.
When I try to install pywin32 with pip (which is how I normally install modules when a virtualenv is active), I get the error:
Could not find any downloads that satisfy the requirement pywin32
No distributions at all found for pywin32
...even though pywin32 is one of the modules listed in the output of
pip search pywin32
Therefore, to install pywin32 at all I had to install it using an *.exe installer downloaded from SourceForge.
Is there any way to install pywin32 within a virtualenv?
UPDATE 2016
There is now a version of pywin32 on PyPI that can be installed with pip. It is called pypiwin32, and it installs the package using the binary wheel format.
https://pypi.python.org/pypi/pypiwin32
pip install pypiwin32
That will work in a virtualenv, or with tox, etc.
Below this line is my previous old answer. That is now outdated information.
OLD ANSWER - OUTDATED. Modern versions of virtualenv default to --no-site-packages. That means that not having access to global site-packages is now the default behavior.
Sadly, (as of July 2014) you can not pip install pywin32 in to your virtualenv. (here's the bug report)
If you want to get pywin32 running inside a virtualenv, activate the virtualenv and use easy_install and the pywin32 installer exe file. For example
easy_install "C:\Path\To\Downloads\pywin32-219.win32-py3.4.exe"
Related question
Try this:
Download directly
Enable your virtualenv
pip install --no-index --find-links:/local/dir/ SomePackage
Check out #8 on pip-installer.org (sorry no permalink)/
Create a virtualenv and activate it:
cd c:\Users\ernesto.luzon
virtualenv --no-site-packages py351env
py351env\Scripts\activate
From here, you have two options:
Download pywin32 from sourceforge project:
http://sourceforge.net/projects/pywin32/files/pywin32/
Download pywin32 from unofficial (but very helpful) binary site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32
Make sure you download the correct version for the Python Interpreter installed in your environment, otherwise you will encounter ImportError: DLL load failed: %1 is not a valid Win32 application later.
If you downloaded from sourceforge, install it using easy_install:
(py351env) C:\Users\ernesto.luzon\Downloads>easy_install pywin32-220.win-amd64-py3.5.exe
If you downloaded from gohlke, install it using pip:
(py351env) C:\Users\ernesto.luzon\Downloads>pip install pywin32-220-cp35-none-win_amd64.whl
In case you encounter ImportError: DLL load failed: The specified module could not be found error later on, you need these additional steps:
Run the post install script:
(py351env) C:\Users\ernesto.luzon>python py351env\Scripts\pywin32_postinstall.py -install
Copied pythoncom35.dll to C:\Users\ernesto.luzon\py351env\pythoncom35.dll
Copied pywintypes35.dll to C:\Users\ernesto.luzon\py351env\pywintypes35.dll
....
Notice where it copied the 'pythoncom35.dll' and 'pywintypes35.dll' files. You need to move these files to the folder:
C:\Users\ernesto.luzon\py351env\Lib\site-packages\win32