I know this question has been asked and answered a number of times but none of those solutions have worked for me. I have installed Python 2.7 into a local directory and added it to my path. When I try to install numpy i get the following error:
ImportError: No module named setuptools
I cannot simply sudo apt-get install python-setuptools because i don't have root access.
I need to install numpy and ideally have pip working for future applications.
0) Try to install packages that are isolated to the current user, use the --user flag:
pip install --user SomeProject
1a) I agree with #Pi Marillion here, use an isolated conda environment if you don't have root access. This way you keep your path clean.
To install conda:
Since I don't know about your OS, go to https://docs.conda.io/en/latest/miniconda.html
After installation, update your conda (just in case):
conda update conda
To list the installed packages, you can do
conda list
You should see python installed. you can start an interpreter by typing python in the terminal.
There's conda cheat sheet that I found incredibly helpful:
https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html
b) Now try installing via pip and I think you might need python 3.x for setuptools.
https://packaging.python.org/tutorials/installing-packages/#id13
2) If this does not work you can still try
https://packaging.python.org/guides/installing-stand-alone-command-line-tools/
Hope this helps :)
First try easy_install --user setuptools pip. If that doesn't work you need to install things manually.
Download setuptools-*.zip from https://pypi.org/project/setuptools/#files. Unzip the archive, cd into the new directory and run python2.7 setup.py install.
Then try pip install. If it still doesn't work reinstall pip: download get-pip.py and run python get-pip.py --user.
Related
I am learning Python and use Anaconda navigator 1.8.7 and Spyder 3.3.0 (Python 3.6.6 32 bits, QT 5.9.4, PyQt5 5.9.2 on Windows). I would like to install a package called 'fix_yahoo_finance' without using pip since I have read that pip creates problems for Anaconda users.
I know that this is the line of code used when using pip:
pip install fix_yahoo_finance --upgrade --no-cache-dir
When I tried using
conda install fix_yahoo_finance
and I get a 'Solving environment: failed'
How do I get this package without using pip? Is there an alternative way that I could run this package in Anaconda like placing it in the pkgs folder?? I am absolutely confused and would really appreciate your help on this.
Thanks a lot in advance.
You can actually install it from other way around as well, clone this repo into your local system.
git clone https://github.com/ranaroussi/fix-yahoo-finance.git
Then go to the directory fix-yahoo-finance or any dir that you have cloned the repo. Then run sudo python3 setup.py install
This way too you can install the package without using pip, but make sure your python is pointing to the Anaconda's python, otherwise the only way to install it would be to copy the package folder from the site-pacakges and paste inside the Conda's package folder. Also you can look around your conda install error, https://github.com/conda/conda/issues/6390
I am using a form of Lubuntu called GalliumOS (optimized for Chromebooks). I installed pip using $ sudo apt-get install python-pip. I then used pip install --user virtualenv and pip install virtualenv, and then when I tried to subsequently use virtualenv venv I experienced the message bash: virtualenv: command not found.
Between the pip installs above, I used pip uninstall virtualenv to get back to square one. The error remained after a reinstall.
I read several other posts, but all of them seemed to deal with similar problems on MacOS. One that came close was installing python pip and virtualenv simultaneously. Since I had already installed pip, I didn't think that these quite applied to my issue. Why is pip install virtualenv not working this way on LUbuntu / GalliumOS?
Are you sure pip install is "failing"? To me, it sounds like the directory to which pip is installing modules on your machine is not in your PATH environment variable, so when virtualenv is installed, your computer has no idea where to find it when you just type in virtualenv.
Find where pip is installing things on your computer, and then check if the directory where the pyenv executable is placed is in your PATH variable (e.g. by doing echo $PATH to print your PATH variable). If it's not, you need to update your PATH variable by adding the following to your .bashrc or .bash_profile or etc.:
export PATH="PATH_TO_WHERE_PIP_PUTS_EXECUTABLES:$PATH"
What finally worked for me was this. I used
$ sudo apt-get install python-virtualenv.
I was then able to create a virtual environment using $ virtualenv venv.
I was seeking to avoid using $ sudo pip install virtualenv, because of admonitions in other posts to not do this, and agreed, because of experiences I'd had with subsequent difficulties when doing this.
pip install virtualenv
This command worked for me for. This problem that raised to me on Kali Linux.
I have dutifully uninstalled all the Python packages I installed with sudo pip install and installed them with pip --user install instead. Yay me :)
On Ubuntu, I know I can find the relevant binaries at /home/<USERNAME>/.local/bin and the packages themselves at /home/<USERNAME>/.local/lib/python2.7/site-packages ... but navigating there is not as simple as good old pip freeze.
How can I pip freeze and get only the packages I installed with pip --user install rather than all the Python packages, including those installed via apt?
Currently pip does not have any such options. So with default pip its not possible. (and I submitted a feature request and now there is a working PR too!)
However I wrote a little script, which does solve your problem:
# pip_user_installs.py
import sys
import pkg_resources
for module in pkg_resources.working_set:
if sys.argv[1] in module.location:
print module.project_name
usage:
$ python pip_user_installs.py $HOME
It's fairly easy in recent versions of pip (the PR in the other answer is now part of pip).
pip freeze --user
This will output a list of packages currently installed to the user's site-packages.
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
I've been trying to use sudo to install python packages on a system that I am on the sudoers list, but don't have general root access (i.e. don't have the password for su). I can install packages, for example
sudo pip install django
however when I try and use them python simply claims not to have the package installed. Investigating the contents of /usr/lib/python it appears that other packages directories and .eggs have executable permissions for ugo, however the packages I install using sudo pip do not have this permission. Manually giving these files executable permissions fixes the problem, but that is laborious, particularly when pip installed several dependencies that I need to chase up.
Is this a known issue? What can I do about it? For the record this is a RHEL6.4 machine and I'm using pip 1.4.1.
You best bet is virtualenv Do your workaround to install the virtualenv.
sudo pip install virtualenv
Resources for virtualenv to get you started:
http://simononsoftware.com/virtualenv-tutorial/
http://www.virtualenv.org/en/latest/