python3 setup.py install is failing (RHEL 8) - python

Issue:
#python3 setup.py install
is failing
Environment: RHEL 8 UBI container
I have a setup.py that looks like this: (any pointers or updates on this setup.py would be appreciated)
import setuptools
print('python/setup.py')
setuptools.setup(
name="process_data",
version="1.0",
description="desc",
author="FirstName LastName",
author_email="dude#abides.abide",
url="https://some.com",
packages=setuptools.find_packages(),
)
I have a directory structure like so (<some>.py in every directory, along with __init__.py):
python/
setup.py
<dir>/__init__.py
<dir>/__init__.py
<dir4>/__init__.py
<dir4>/<sub-dir1>/__init__.py
<dir4>/<sub-dir1>/<sub-dir>__init__.py
I want code in each of these directories to be part of a module package so I can import, nested however deep.
I'm doing this:
#cd python
#python3 setup.py install
I get this error:
python/setup.py
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
/usr/local/lib/python3.6/site-packages/test-easy-install-1625.write-test
[Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/test-easy-install-1625.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python3.6/site-packages/
This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
Questions:
Where is this coming from: test-easy-install-1625.write-test ? (so confused as to what this is)
On my system, indeed this directory does not exist (why is python3 setup.py install looking there? what told it to look there?):
/usr/local/lib/python3.6
There is nothing in my setup.py to indicate to look there.
I looked all over, and it looks like my /site-packages/ directory is here (where other modules are installed, when I ran pip)
`/usr/local/lib64/python3.6/site-packages/`
How do I fix this?
Thank you, I so badly need to get this working right away. I have been working on Windows, and >python setup.py install simply works there.
Are there any env variables I should have setup?
I simply installed python with: dnf -y install python36 that's it. (the latest version available in any RHEL 8 package repo for installation).

I ran into this same error and I was able to fix it by creating a symbolic link. I accept someone else maybe able to offer a more elegant solution and I welcome it.
sudo mkdir /usr/local/lib/python3.6
sudo ln -s /usr/lib/python3.6/site-packages /usr/local/lib/python3.6/

I assume you had enter python command mode, if you don't, the following commands are needed, notice to set variable Path and PythonPath of yours:
setlocal
set env_name=python3.6
set Path=C:\Users\s41167\Miniconda3\envs\%env_name%;C:\Users\s41167\Miniconda3\envs\%env_name%\Scripts;%Path%
set PythonPath=C:\Users\s41167\Miniconda3\envs\%env_name%\Lib\site-packages
cd C:\Users\s41167\Documents\%env_name%
cmd.exe /K activate %env_name%
if you enter python command mode, you can use pip to insall the package:
pip install <package location> --target <install location> --upgrade
below is my install command and result:
(python3.6) C:\Users\s41167\Documents\python3.6>pip install ./python_package --t
arget ./target --upgrade
Processing c:\users\s41167\documents\python3.6\python_package
Building wheels for collected packages: process-data
Building wheel for process-data (setup.py) ... done
Created wheel for process-data: filename=process_data-1.0-cp36-none-any.whl si
ze=1721 sha256=ef5eaf061000f30d472e5dde268694733e40a3f8a4a29fa78faec69f125443c9
Stored in directory: C:\Users\s41167\AppData\Local\Temp\pip-ephem-wheel-cache-
v6lt_ndp\wheels\61\01\f5\07e0760baa10d63e1c43b37eadbb55b79828f4fe337209026a
Successfully built process-data
Installing collected packages: process-data
Successfully installed process-data-1.0
(python3.6) C:\Users\s41167\Documents\python3.6>
and the file arrangement:
.\python_package
__init__.py
setup.py
\directory
__init__.py
\directory4
__init__.py
\sub_dirctory1
__init__.py

in Linux use
sudo python3 setup.py install
in windows use
python setup.py install
or
python3 setup.py install

Related

Error while installing Jupyter: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

I tried installing Jupyter through pip and it failed showing this.
The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been
aborted.
This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please, inform the package's author and the
EasyInstall maintainers to find out if a fix or workaround is
available.
Try to upgrade your packages:
pip install --upgrade setuptools
pip install --upgrade pip
its seems like missmatch in your versions
simply follow this to install jupyter in windows :-
1nd - Go to file manager and find python folder (like:-python,python37,python39 etc...) may be it's in (C:\Python39) or (C:\Users\prade\AppData\Local\Programs\python39) .
2rd - in python folder open Scripts folder (Ex:- C:\......\python39\Scripts) and copy this path.
3rd - run cmd as administrator and past above path using cd (like:- cd C:\.....\python39\Scripts)
4th - now simply use jupyter install command (like:- pip install jupyterlab)

How do I install a package from GitHub gist?

I don't understand this...
I want to install this https://gist.github.com/sixtenbe/1178136.
It is a peak detection script for python.
Everywhere I look I am told to use pip with the .git extension.
All I see is how to download the .zip, but from there I am lost.
How can I install this?
Thanks.
You can get the individual files in the Gist (or download the Gist as an ZIP and extract) and put them in your source code folder.
Then you will be able to import them as modules in your own scripts:
import analytic_wfm as AW
AW.ACV_A6( ... )
import peakdetect as PK
PK.peakdetect_parabola( ... )
Let's give it another look.
By "installing a package" we might mean that the package should be available via import.
For that the package directory should reside either in the current directory or in one of the other directories in the import search path.
One such directory is the "user-specific site-packages directory, USER_SITE":
python -c "import site; print(site.getusersitepackages())"
Git URL
First we might need a Git URL. Going to https://gist.github.com/sixtenbe/1178136 we can click on the Embed pop-up and switch it to Clone via HTTPS:
in order to obtain the GIT URL: https://gist.github.com/1178136.git.
git and bash
Having the Git URL and the Unix shell (bash) we can install the package manually into the USER_SITE.
Let's go into the USER_SITE first:
cd $(python -c "import site; print(site.getusersitepackages())")
pwd
Now that we are in the USER_SITE, let's download the Gist:
git clone https://gist.github.com/1178136.git analytic_wfm
Finally, let's verify that the package is now available:
cd && python -c "import analytic_wfm.analytic_wfm; print(analytic_wfm.analytic_wfm.__all__)"
If numpy is installed, it prints
['ACV_A1', 'ACV_A2', 'ACV_A3', 'ACV_A4', 'ACV_A5', 'ACV_A6', 'ACV_A7', 'ACV_A8']
pip
Let's try to install a Gist package with pip.
For pip install we should prefix the Git URL with git+:
pip install --user git+https://gist.github.com/1178136.git
This gives us the error:
ERROR: git+https://gist.github.com/1178136.git does not appear to be a
Python project: neither 'setup.py' nor 'pyproject.toml' found.
Looks like the package we've picked is missing the necessary pip configuration!
Let's try another one:
pip install --user git+https://gist.github.com/bf91613a021a536c7ce16cdba9168604.git
Installs NP:
Successfully built llog
Installing collected packages: llog
Successfully installed llog-1.0
Particularly because it has the setup.py.
Note also that Gist does not support subfolders, and pip seems to depend on them in handling the packages argument, but the code in setup.py can workaround this by creating the package subfolder on the fly and copying the Python files there!
Hence if you want to import that Gist, https://gist.github.com/sixtenbe/1178136, with the rest of the requirements.txt dependencies, - you can fork it and add setup.py to the effect.
pypi
Given that the analytic-wfm can also be found at the Python Package Index, https://pypi.org/project/analytic-wfm/, you can install it with
pip install analytic-wfm

How to find pg_config path

Complete newbie here, trying to set up Django to work with PostgreSQL.
I'm using mac osx 10.6.8. I have also installed PostgreSQL 9.3
When I run pip install psycopg2 in terminal I get the following error
Downloading/unpacking psycopg2
Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
Running setup.py (path:/private/var/folders/A9/A99cs6x0FNusPejCVkYNTE+++TI/-Tmp-/pip_build_bengorman/psycopg2/setup.py) egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
I've seen a number of posts on this
how-to-install-psycopg2-with-pip-on-python
pg-config-executable-not-found
but I have no clue how to find the bin folder location containing pg_config. Any tips on finding this path?
I recommend that you try to use Postgres.app. (http://postgresapp.com)
This way you can easily turn Postgres on and off on your Mac.
Once you do, add the path to Postgres to your .profile file by appending the following:
PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
Only after you added Postgres to your path you can try to install psycopg2 either within a virtual environment (using pip) or into your global site packages.
sudo find / -name "pg_config" -print
The answer is /Library/PostgreSQL/9.1/bin/pg_config in my configuration (MAC Maverick)
Installing homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
And then installing postgresql
brew install postgresql
gave me this lovely bit of output:
checking for pg_config... yes
ahhh yeahhhhh
Postgres.app was updated recently. Now it stores all the binaries in "Versions" folder
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
Where 9.4 – version of PostgreSQL.
Once you install the current PostgreSQL app on the MacOS X 10.11, this is where the pg_config file is /Library/PostgreSQL/9.5/bin/pg_config.
Then on the Terminal:
$ export PG_HOME=/Library/PostgreSQL/9.5
$ export PATH=$PATH:$PG_HOME/bin
This will put the path in the .profile of whatever terminal you are using.
In your environment (assuming you are using virtualenv) you then install psycopg2:
$ pip install psycopg2
You should see if you had downloaded it before:
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.6.1
To summarize -- PostgreSQL installs its files (including its binary or executable files) in different locations, depending on the version number and the installation method.
Some of the possibilities:
/usr/local/bin/
/Library/PostgreSQL/9.2/bin/
/Applications/Postgres93.app/Contents/MacOS/bin/
/Applications/Postgres.app/Contents/Versions/9.3/bin/
No wonder people get confused!
Also, if your $PATH environment variable includes a path to the directory that includes an executable file (to confirm this, use echo $PATH on the command line) then you can run which pg_config, which psql, etc. to find out where the file is located.
I had exactly the same error, but I installed postgreSQL through brew and re-run the original command and it worked perfectly :
brew install postgresql
This is how to simply get the path of pg_config
$ which pg_config // prints the directory location
/usr/bin/pg_config
Have same issue on mac, you probably need to
brew install postgresql
then you can run
pip install psycopg2
The brew will fix PATH issue for you
this solution works for me at least.
You can find the pg_config directory using its namesake:
$ pg_config --bindir
/usr/lib/postgresql/9.1/bin
$
Tested on Mac and Debian. The only wrinkle is that I can't see how to find the bindir for different versions of postgres installed on the same machine. It's fairly easy to guess though! :-)
Note: I updated my pg_config to 9.5 on Debian with:
sudo apt-get install postgresql-server-dev-9.5
check /Library/PostgreSQL/9.3/bin and you should find pg_config
I.E. /Library/PostgreSQL/<version_num>/
ps: you can do the following if you deem it necessary for your pg needs -
create a .profile in your ~ directory
export PG_HOME=/Library/PostgreSQL/9.3
export PATH=$PATH:$PG_HOME/bin
You can now use psql or postgres commands from the terminal, and install psycopg2 or any other dependency without issues, plus you can always just ls $PG_HOME/bin when you feel like peeking at your pg_dir.
I used :
export PATH=$PATH:/Library/PostgreSQL/9.6/bin
pip install psycopg2
Works for me by installing the first the following pip packages: libpq-dev and postgresql-common
For people looking for the pg_config path for postgresql installed via brew on Apple silicon: /opt/homebrew/Cellar/postgresql/<postgres_version>/bin.
For Intel based Mac system /usr/local/Cellar/postgresql/<postgres_version>/bin (Need to verify this).
For those using macOS Big Sur and have their default shell as the Z shell, you can add the path to the py_config binary in the .zprofile which is equivalent to the .bash_profile as explained in this link https://support.apple.com/en-us/HT208050
I had similar issues when using PyCharm with a virtual environment within which I was unable to change my shell to bash to get things going. Adding the postgres bin path fixed my issue:
MacBook-Pro ~ % cat .zprofile
# Setting PATH for Postgres
PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
export PATH
Then running this worked without any issues:
pip install psycopg2
path of pg_config in my case (MacOS)
/Library/PostgreSQL/13/bin
Execute the following in the terminal:
PATH="/Library/PostgreSQL/13/bin:$PATH"
Then
pip install psycopg2

Creating a Debian package from Python package via stdeb: what is .deb file?

After typing this command:
python setup.py --command-packages=stdeb.command bdist_deb
I get a folder deb_dist, which contains orig.tar.gz, debian.tar.gz and .dsc file. And where is .deb file?
Am I doing something wrong or this is right? I`m new in packaging and do not understand all details.
You should install dependence:
apt-get install python-stdeb fakeroot python-all
After typing the command:
python setup.py --command-packages=stdeb.command bdist_deb
The directory deb_dist will be contain deb package. You can look on http://shallowsky.com/blog/programming/python-debian-packages-w-stdeb.html

pip install customized include path

I'm trying to install a library pyleargist. It requires another lib libfftw3 to be manually installed which I've installed. Since I don't have the root privilege, I have to install libfftw3 under my home directory: ~/usr/include and ~/usr/lib. Then I follow this post: https://superuser.com/questions/242190/how-to-install-matplotlib-on-os-x, added:
export LDFLAGS="-L~/usr/lib"
export CFLAGS="-I~/usr/include
So that pip knows it have to consult /usr to get the include (.h files) and lib (.a, *.so files). However, while running pip install --user pyleargist, it complains about:
gcc-4.4.real: src/leargist.c: No such file or directory
gcc-4.4.real: no input files
error: command 'gcc' failed with exit status 1
I guess what happened is that the path is incorrect so that it can't find the *.c files (I think pip should have downloaded the file somewhere but not sure where it is).
So my questions are the following: 1) in this particular case, how can I install pyleargist with include and lib path under ~/usr? 2) more generally, how can one provide additional path for pip so that it knows where to get the additional include files or libs if not found in the default path?
p.s I am on an ubuntu machine without sudo privilege.
ref:
https://pypi.python.org/pypi/pyleargist/1.0.1
http://www.fftw.org/
pip has a --global-option flag
You can use it to pass additional flags to build_ext.
For instance, to add a -I flag:
pip install --global-option=build_ext --global-option="-I/home/users/abc/include/" pyOpenSSL
This was a helpful thread. Just to add on to this, you can also use pip without root if you pass the --user flag at the end:
pip install --global-option="-I/home/users/abc/include/" mpi4py --user
For example, if you're using python-v2.7, the above command installs the python package to /home/username/.local/lib/python2.7/site-packages
if you dont have root you can get a virtual enviroment no root is needed to get one and your path will be in home
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.10.1.tar.gz
tar xvfz virtualenv-1.10.1.tar.gz
cd virtualenv-1.10.1.tar.gz
python virtualenv.py myVE
then your path is set in your home:
cd myVE/bin
./python
>>> import sys
>>> sys.path
['', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python33.zip', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3/plat-linux', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3/lib-dynload', '/usr/lib64/python3.3', '/usr/lib/python3.3', '/usr/lib/python3.3/plat-linux', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3/site-packages']
>>>

Categories

Resources