Installing Python Module to non-root directory - python

First time posting on this site.
I'm trying to install a python module named Pygments into my local directory at work (non-root). I am using C Shell, so i changed default path using
setenv PYTHONPATH "~/usr/lib/python2.4/site-packages:${PYTHONPATH}"
(with usr/lib/... being self-made empty directories made to mimic the system's hierarchy at my boss's suggestion). I attempted to run
python setup.py install
however, I got the following error.
/usr/lib64/python2.4/distutils/dist.py:236: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
/usr/lib64/python2.4/distutils/dist.py:236: UserWarning: Unknown distribution option: 'include_package_data'
warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
creating /usr/local/lib64
error: could not create '/usr/local/lib64': Read-only file system
I want the module to install to my local directory and not to any root directory. I've been stuck on this for a couple of days. Any help would be greatly appreciated.
Colten
Extra Information: I have setup.py in ~/Pygments-1.6, and I only have write access to directories within ~/.

PYTHONPATH is where python looks for modules, not where it chooses to install modules. You need to specify that on the setup.py line:
python setup.py install --prefix=${HOME}/usr/
or something similar. Another thing that you'll see in these cases is:
python setup.py install --user
which will put it in: '${HOME}/.local/lib/pythonX.Y/site-packages' (And I believe that this path should be searched by python for modules by default.)

Related

Cannot install python packages due to missing site-packages folder on Linux

On Linux, every time I try to install a python package I get an error that the site-packages directory is missing. For example:
error: [Errno 2] No such file or directory: '/opt/python/cp39-cp39/Lib/site-packages/'
One simple solution is to just create the missing directory; however, this is not possible in certain instances. For example, when running python -m build, a venv with a random name is created to build the package in - therefore, I cannot create the site-package folder since there is no pause where I can modify the new venv.
I have tested this on multiple machines, and this issue also appears in GitHub hosted CI/CD runners. This is especially difficult to resolve in CI/CD pipelines because I have no control over additional venvs created by build, cibuildwheel and other PyPA tools.
This error occurs when I run pip install ., python -m build and several other pip commands that involve building wheel packages. The error always occurs while pip is building the wheel.
I would appreciate any suggestions!

Failure to install psycopg2 in Pycharm

I'm trying to install psycopg2 to use a postgresql db in the backend of my django project, but every time I run the pip install psycopg2 command I get an error saying:
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. 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 have added the \bin\ folder containing the file to my path, I've ran the pip install psycopg2-binary command as well, and I've uninstalled and reinstalled posgresql on my computer, I've also ran the python setup.py build_ext command mentioned in the error message, and this error still pops up. I'm operating on a windows 10 os and using posgresql 13.1. Any suggestions?
EDIT: This is the error I'm getting in my terminal:
Error in PyCharm terminal
You've probably done this already, but the steps should be:
Install PostgreSQL.
Add the PostgreSQL bin/ folder to your path.
Restart your command line to make sure your path is set correctly.
Run pip install psycopg2
I have a clean install of Windows 10 over here and it seems to work for me. Running pip install psycopg2-binary should definitely work (even without PostgreSQL) because that doesn't compile anything, so I'm interested if you also have errors there.

CKAN PluginNotFoundException in Pages Extension

I'm using CKAN as my open data portal. It's written in Python using Pylons framework. I want to integrate ckanext-pages plugin. So I used below steps.
1. . /usr/lib/ckan/default/bin/activate
2. pip install -e 'git+https://github.com/ckan/ckanext-pages.git#egg=ckanext-pages'
3. cd /usr/lib/ckan/default/src/ckanext-pages
4. python setup.py develop
Still I get below exception. Given that I tried restart CKAN and Apache server.
ckan.plugins.core.PluginNotFoundException: pages
But when I run the python setup.py develop command it still that plugin is install correctly. Please see the output below.
running develop
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
running egg_info
writing ckanext_pages.egg-info/PKG-INFO
writing namespace_packages to ckanext_pages.egg-info/namespace_packages.txt
writing top-level names to ckanext_pages.egg-info/top_level.txt
writing dependency_links to ckanext_pages.egg-info/dependency_links.txt
writing entry points to ckanext_pages.egg-info/entry_points.txt
WARNING: ckanext is a namespace package, but its __init__.py does
not declare_namespace(); setuptools 0.7 will REQUIRE this!
(See the setuptools manual under "Namespace Packages" for details.)
reading manifest file 'ckanext_pages.egg-info/SOURCES.txt'
writing manifest file 'ckanext_pages.egg-info/SOURCES.txt'
running build_ext
Creating /usr/local/lib/python2.7/dist-packages/ckanext-pages.egg-link (link to .)
Removing ckanext-pages 0.1 from easy-install.pth file
Adding ckanext-pages 0.1 to easy-install.pth file
Installed /usr/lib/ckan/default/src/ckanext-pages
Processing dependencies for ckanext-pages==0.1
Finished processing dependencies for ckanext-pages==0.1
Even though it says that plugin is installed correctly, exception is occurred. How can I fix this?
You have installed the packages into the system Python (/usr/local/lib/python2.7/dist-packages). Make sure that you use the pip and python from the virtualenv. It seems that the virtualenv is not activated at all. Try executing source /usr/lib/ckan/default/bin/activate
You could also try to call pip and python with the absolute path of the virtualenv.

Setup tools install command differences

What are the differences between the below commands
python setup.py install develop
Doesn't work for me error No such file or directory: 'build/bdist.macosx-10.7-intel/egg/test-easy-install-37886.pth'
python setup.py develop
Works for me appears to make an .egg link file
python setup.py install
Works for me appears to make a .egg file which in .zip file format
Develop is a setuptools / distribute feature that allows you to add a project
to your Python environment without installing it - so you can continue
its "development"
In other words, when you call "python setup.py develop", setuptools will
compile the metadata and hook your project into Python's site-package,
but the packages and modules that will be used are the one in the
directory where you've run that command.
This is useful to continue working on your code and testing it without
having to run "python setup.py install" on every run
With develop, Python 'pseudo-installs' a package by running the setup.py script instead of install. The difference is a modification of the environment (it doesn't with develop), so a package can be imported from it's current location instead of a site-package directory. The advantage of this is you can develop packages that are being used by other packages, and you can modify source code in place with develop.
As far as "setup.py install develop", I've never seen anyone use that before, sorry.
source
source
source
python setup.py install develop
Is a wrong command.
When you use develop you use the current code when you run your application.
When you useĀ install and then modify you code, your modifications will not be taken in account while running your app. until you rerun install or develop.

Can not install hcluster from pypi under python 2.6 on xp

I am using the setup.py file supplied with hcluster with the following lines added:
sys.path.append("c:\\Program Files\\Python26\\Lib\\site-packages\\hcluster-0.2.0")
sys.path.append("c:\\Program Files\\Python26\\Lib\\site-packages\\hcluster-0.2.0\\hcluster")
Then used setup.py as follows:
"c:\program files\python26\python.exe" "c:\Program Files\Python26\Lib\site-packages\hcluster-0.2.0\setup.py" install
I get the following error messages:
running install
running build
running build_py
error: package directory 'hcluster' does not exist
Don't know if it trying to read or write hcluster.
Any help appreciated
You don't need to add packages in site-packages in sys.path.
Did you copy the hcluster in site-package manually? It is not the correct way to do it.
2.1 You should have the hcluster outside the site-packages say in your home directory and then run "python setup.py install"
2.2 This will put the package after build into site-package directory. This is where all external package reside by default after they are installed.
Remove the folders related to hcluster from site-packages and install with instruction 2.
Read the following to understand your error: http://docs.python.org/install/index.html

Categories

Resources