I have what seems a simple question though I could not find a solution. I want to install a library (TIGRE), which comes with a setup.pyfile, to my conda-environment. In order to do that, I'm running pip install ., of course with the environment activated.
Nevertheless, python gives me the following error
Traceback (most recent call last):
File "C:\Users\***\Miniconda3\envs\tigre3.9\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
main()
...
...
File "C:\Users\***\AppData\Local\Temp\pip-build-env-4t_kjciu\overlay\Lib\site-packages\setuptools\build_meta.py", line 174, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 11, in <module>
from Cython.Distutils import build_ext
ModuleNotFoundError: No module named 'Cython'
even though Cython is infact installed in that exact same environment. Running python setup.py install runs fine however. What could be the cause of this problem? Why doesn't pip find the package when installing, but finds it e.g. with pip freeze?
Since there is something else wrong with the library I wanted to follow the installation guide step-by-step and use pip install ., because obviously both commands are not the exact same.
Thank you!
Related
So I was able to install sklearn for python2 but for some reason I having issues with doing the same for python3. I am getting this error:
Traceback (most recent call last):
File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 44, in <module>
from ._check_build import check_build # noqa
ImportError: /home/ajshack_pg/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ajshack_pg/sklearn/__init__.py", line 133, in <module>
from . import __check_build
File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: /home/ajshack_pg/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
___________________________________________________________________________
Contents of /home/ajshack_pg/sklearn/__check_build:
setup.py setup.pyc __init__.pyc
_check_build.so __init__.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
I tried to go into the source directory and type in what they say to no avail. Any insight here?
Thanks!
If you installed sklearn from source for Python 2.x, some of its binaries may have persisted if you didn't fully remove all sklearn files. Python 2.x and 3.x are quite incompatible with each other, so this might be a reason why it's failing to build.
A few steps to take:
Consider using a virtualenv for your sklearn projects, especially if you have a lot of different packages or Python versions floating around. It's great for keeping different development environments with different Python packages and libraries isolated. Follow this guide if you don't have it already. When creating your virtualenv, make sure to install it with Python 3.x by using this command when creating your virtualenv:
virtualenv -p python3 envname
If building from source: Redownload the sklearn source for your Python 3 version and place it in your virtualenv. Closely follow all build instructions. That should hopefully give you a clean install of sklearn.
If installing with pip: Activate your virtualenv, then:
pip install -U scikit-learn after installing numpy and scipy.
>pip
Traceback (most recent call last):
File "/usr/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 49, in <module>
from pkg_resources.extern import six
File "/usr/lib/python3.6/site-packages/pkg_resources/extern/__init__.py", line 61, in load_module
"distribution.".format(**locals())
ImportError: The 'six' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
I did reinstall with pacman -S python as well as pacman -S python-setuptools, pacman -S python-packaging, and pacman -S python-six, nothing helps.
Almost every other python applications follow the same pattern now (such as qutebrowser and buku.
I think it happened right after I installed vmware-vcli manually following the ArchWiki guide on the topic (I know its perl and might be unrelated though).
Downgrading python-setuptools as suggesting in similar posts by installing the earlier version in /var/cache/pacman/pkg did not fix the problem.
I faced exactly the same problem running pip3 install --upgrade pip.
However, pip3.5 install --upgrade pip worked for me. After this upgrade the error message of pip3 disappeared.
I am trying to install ruamel.yaml python library in a Centos 7 machine where I don't have internet connection. I tried this:
installed libyaml-devel, python-devel, python-pip using a local repository
downloaded ruamel.yaml-0.13.14.tar & ruamel.ordereddict-0.4.6.tar(dependency) from pypi.
now I am able to install ruamel.ordereddict using pip install .,
but when I tried to install ruamel.yaml in the same way, I got the following exception:
[root#limulus ruamel.yaml-0.13.14]# pip install .
Processing /tmp/python/ruamel.yaml-0.13.14
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 7, in <module>
from setuptools.command.install import install
File "/usr/lib/python2.7/site-packages/setuptools/command/__init__.py", line 8, in <module>
from setuptools.command import install_scripts
File "/usr/lib/python2.7/site-packages/setuptools/command/install_scripts.py", line 3, in <module>
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 74, in <module>
import parser
File "parser.py", line 77, in <module>
from ruamel.yaml.error import MarkedYAMLError # type: ignore
File "/usr/lib64/python2.7/site-packages/ruamel/__init__.py", line 5, in <module>
__import__('pkg_resources').declare_namespace(__name__)
AttributeError: 'module' object has no attribute 'declare_namespace'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-oOWX1x-build/
What is the correct way of installing a python library in offline mode?
It looks like you have been expanding the tar files, which is not necessary, but I am not sure if that is the reason why you get this error, you probably are also missing the typing dependency.
What you shouldn't do is use the system installed pip, it is almost out of date and on some systems actually causes problems because of unfixed bugs in those old versions.
What you also should not do is install packages using pip outside of a Python virtualenv, as this might break your system when it updates/overwrites things in the systems site-packages/dist-packages directory. The solution provided below only installs pip/wheels/virtualenv in the system directory, that is AFAIK safe, but there are ways around that as well if it would necessary.
You should also consider using the provided wheels to install packages. That way C extension don't need compilation.
On a machine that is online do:
mkdir /tmp/offline
cd /tmp/offline
# your python-pip installed pip might not support wheels
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
wget https://pypi.python.org/packages/a7/37/947b4329c4a3c72093b6c8e9b4be8c7f10c32dbb78848d3a234ce01c059d/wheel-0.30.0a0.tar.gz
wget https://pypi.python.org/packages/6f/86/3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/virtualenv-15.1.0-py2.py3-none-any.whl
Now download the required wheels (.tar.gz if not available):
wget https://pypi.python.org/packages/96/4b/5251bf469f37e49e0c92f841b5b3ef01a1c9d652cc018df470e5ae235eb8/ruamel.ordereddict-0.4.9-cp27-cp27mu-manylinux1_x86_64.whl
wget https://pypi.python.org/packages/63/40/c38b857ec6a083e534ee9a9f655741120d4bfd9139232681f976cf44272b/ruamel.yaml-0.13.14-cp27-cp27mu-manylinux1_x86_64.whl
wget https://pypi.python.org/packages/b6/0c/53c42edca789378b8c05a5496e689f44e5dd82bc6861d1ae5a926ee51b84/typing-3.5.3.0.tar.gz
Copy the six files to a new directory your offline system, and there do
sudo pip install pip*.tar.gz wheel*.tar.gz
sudo pip install virtualenv*
virtualenv ~/ruamel
source ~/ruamel/bin/activate
pip install typing* ruamel*
That gives you a virtualenv with ruamel.yaml installed, just add your application in there as well.
The downloads used here are current as of 2017-01-07, you can get more up-to-date ones using your browser (on the on-line system) if necessary.
When trying to install the python package progressbar on OSX El Capitan, I get the following error:
Collecting progressbar
Using cached progressbar-2.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/var/folders/9s/b1jly7yd0jq639plvkzdvn4m0000gn/T/pip-build-xhfxywsw/progressbar/setup.py", line 5, in <module>
import progressbar
File "/private/var/folders/9s/b1jly7yd0jq639plvkzdvn4m0000gn/T/pip-build-xhfxywsw/progressbar/progressbar/__init__.py", line 59, in <module>
from progressbar.widgets import *
File "/private/var/folders/9s/b1jly7yd0jq639plvkzdvn4m0000gn/T/pip-build-xhfxywsw/progressbar/progressbar/widgets.py", line 121, in <module>
class FileTransferSpeed(Widget):
File "/Users/<USERNAME>/anaconda/lib/python3.4/abc.py", line 133, in __new__
cls = super().__new__(mcls, name, bases, namespace)
ValueError: 'format' in __slots__ conflicts with class variable
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/9s/b1jly7yd0jq639plvkzdvn4m0000gn/T/pip-build-xhfxywsw/progressbar
Updating the following did not solve my problem
pip install --upgrade setuptools
pip install --upgrade Distribute
How can I solve that?
The original package does not work with python3, however, there's a fork that does, you can clone it from https://github.com/coagulant/progressbar-python3.git and run
python3 setup.py install
I dind't, however, check whether the functionality works per se, so YMMV, but it installs at least :)
[edit]
Update by #shadi 30 Jan 2017: Issue 28 on progressbar's github repo says to use pip3 install progressbar33,
thanks!
I used pip3 install progressbar33 but when i installed autosub
ValueError: 'format' in slots conflicts with class variable
I have a number of django projects organized with the following directory structure using win7 (I'm using GIT_BASH/mingw for my command line) :
envs--r1--project1
--project2
--Include
--Library
--Scripts--python.exe
python275--
The idea being here that the different projects have a common environment and I can activate that environment from each projects root directory using:
$ source ../Scripts/activate
I don't understand exactly how it happened but it turned out that the interpreter ( listed above as python.exe ) was linked somehow to a second python folder above.
I deleted the python275 folder ( AAHH!!) , not realizing its importance, resulting in:
Traceback (most recent call last): File "C:\envs\r1\lib\site.py", line 703, in main() File "C:\envs\r1\lib\site.py", line 692, in main aliasmbcs() File "C:\envs\r1\lib\site.py", line 515, in aliasmbcs import locale, codecs File "C:\envs\r1\lib\locale.py", line 19, in import functools ImportError: No module named functools
I have reinstalled the correct python folder but the error persists. Can anyone advise me on how to rebuild the virtualenvs so I can go back to the way it was?
edit:
(r1)
/C/envs/r1/Scripts
$ import reload(functools)
sh: syntax error near unexpected token `('
(r1)
/C/envs/r1/Scripts
$ python.exe import reload(functools)
sh: syntax error near unexpected token `('
(r1)
/C/envs/r1/Scripts
$ python.exe reload functools
Traceback (most recent call last):
File "C:\envs\r1\lib\site.py", line 703, in <module>
main()
File "C:\envs\r1\lib\site.py", line 692, in main
aliasmbcs()
File "C:\envs\r1\lib\site.py", line 515, in aliasmbcs
import locale, codecs
File "C:\envs\r1\lib\locale.py", line 19, in <module>
import functools
ImportError: No module named functools
(r1)
/C/envs/r1/Scripts
$ reload(functools)
sh: syntax error near unexpected token `('
(r1)
/C/envs/r1/Scripts
$ python.exe reload(functools)
sh: syntax error near unexpected token `('
(r1)
/C/envs/r1/Scripts
$ python.exe test.py
Traceback (most recent call last):
File "f:\envs\r1\lib\site.py", line 703, in <module>
main()
File "f:\envs\r1\lib\site.py", line 692, in main
aliasmbcs()
File "f:\envs\r1\lib\site.py", line 515, in aliasmbcs
import locale, codecs
File "f:\envs\r1\lib\locale.py", line 19, in <module>
import functools
ImportError: No module named functools
I suggest reinstalling Python and virtualenv from scratch in your case, and then re-creating the environment(s).
Make sure you have a working Python 2.7.5 installation on your system.
Make sure you have pip installed (see docs).
Make sure pip is linked to the Python installation above (check the output of pip -V, it should contain the correct system-wide Python path).
Do a clean install of virtualenv using pip install virtualenv.
Create and activate the environment for your projects.
Reinstall within your new environment all the modules you had installed in your old environment.
This may be a tricky one.
If you have an up-to-date file such as requirements.txt
with all the packages required, then
you're all set (pip install -r requirements.txt should do it).
If you don't have requirements listed, or they aren't up-to-date, then
check manually which packages you had installed in your old environment.
For that you should locate site-packages directory within your old virtualenv
(should be under Library probably) and look what's in there.
Every non-system package you recognize in site-packages directory
you install into your new environment (normally using pip install but
some packages may have custom instructions).
That's what I did when it happened to me. I wasn't able to simply rebuild the environment, so I did the reinstall for cleanness.
Taken from other post. You can associate the virtualenv to a python version.
You indicate the Python interpreter to use with the flag -p or --python (e.g --python=python2.5)
virtualenv -p /usr/bin/python2.6 <path/to/new/virtualenv/>
But this is just works for creating new environments. You would need to access your old virtualenv and execute:
pip freeze > requirements.txt
The file requirements.txt would contain all the apps you installed in the old virtual environment and their respective versions. Now, from the new environment you have created, run:
pip install -r requirements.txt
You should active the virtual environment.
$ source /yourvirtualenvpath/bin/activate
$ pip freeze > /home/user/requirements.txt
$ deactivate
$ source /yourNEWvirtualenvpath/bin/activate
$ pip install -r /home/user/requirements.txt