I have multiple issue
First issue:
I have a server which is so secure that is running
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.4
There is no internet connectivity there and I want to download some packages like
pysnmp
pandas
numpy
psutil
some others
As per my research, the best way to download from server that has internet and transfer the file to the server that does not have an internet.
I tried of things, like download tar.gz of the package or use basket or take full package but no use
Second issue:
While I am trying, I am getting No module named pkg_resources error.Hhow can I solve that first in-order to proceed?
my python version is
python2 is 2.7.5
python3 is 3.4.9
i am tried pip install pysnmp-4.4.12.tar.gz to the main package. it mention to be no Module pk_resource.
i tried also to use basket as per the website https://pythonhosted.org/Basket/
and i used easy_install -f ~/.basket -H None pyramid
and i got pkg_resource module error.
However When i download setuptools through the website https://pypi.org/project/setuptools/0.9.8/#installation-instructions
and i use python eazy-setup.py --user the Error is
[Errno 13] Permission denied: '/usr/lib64/python2.7/site-packages/XlsxWriter-1.1.2.dist-info'
Updated !!!!
I managed to do it Thanks for the help
I the problem is dependency tree i suggest running a local pip server : https://pypi.org/project/pypiserver/
and copy all needed package to server you can see it with:
pip freeze
and install your package with:
pip install --extra-index-url http://localhost:8080/simple/
so Here is the solution!!
For this problem:
No module named pkg_resources error
i was using pip install pysnmp or pip install pandas
i should use python -m pip install
the second issue :
the Error is [Errno 13] Permission denied: '/usr/lib64/python2.7/site-packages/XlsxWriter-1.1.2.dist-info'
the solution is sudo python -m pip install
The main reasons is that secured Server is used to have multiple users ( Main user where main function is running)
so using sudo is important
Finally how to install package is easy.
Go to pypi and download
pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl
then sudo python3 -m pip install pandas-0.25.3-cp36-cp36-manylinux1_x86_64.whl
some Tips:
try to use virtual machine like virtual box for testing how to install and once it is install try to browser for it. Why i am saying that because i am running Windows and my server is Redhat so any solution on my windows is useless so i had to use my laptop with virtual box ( I cant download Virtual box due security)
second thing, python is different than python3 so if you use python in your virtual box which is host Linux server , you will get pandas-0.25.3-cp27-cp27-manylinux1_x86_64.whl not pandas-0.25.3-cp36-cp36-manylinux1_x86_64.whl so becareful
and Last tip once you done use sudo python whateveryouwant torun.py
again why sudo because all of your packages are inside main file not inside your user
Hope i managed to answer my self correctly
Related
I'm working on a windows 7 and using Cygwin for unix-like functionality. I can write and run Python scripts fine from the Cygwin console, and the installation of Python packages using pip installis successful and the installed package appears under pip list. However, if I try to run a script that imports these packages, for example the 'aloe' package, I get the error "no such module named 'aloe'".
I have discovered that the packages are being installed to c:\python27\lib\site-packages, i.e. the computer's general list of python packages, and not to /usr/lib/python3.6/site-packages, i.e. the list of python packages available within Cygwin. I don't know how to rectify this though. If I try to specify the install location using easy_install-3.6 aloe I get the error
[Errno 13] Permission denied: '/usr/lib/python3.6/site-packages/test-easy-install-7592.write-test'.
In desperation also tried directly copying the 'aloe' directory to the Cygwin Python packages directory using cmd with cp -r \python27\lib\site-packages\aloe \cygwin\lib\python3.6\site-packages and the move was successful, but the problem persists and when I check in the Cygwin console using ls /usr/lib/python3.6/site-packages I can't see 'aloe'.
I have admin rights to the computer in general (sudo is not available in Cygwin anyway) so really can't figure out what the problem is. Any help would be greatly appreciated.
Thanks.
just make sure you are in admin mode.
i.e. right click on Cygwin, select running as administrator.
then install your package specifically using pip3, for python3.
i.e. pip3 install your_package
with updated version, do pip3 install --upgrade your_package
I am facing problems installing pyobjc on my mac.
Basically I have to install pyobjc on a new Mac System in the system default python. I have so far tried easy_install, pip and downloading the pkg file and installing. All give me a error in different ways. Some give me a error saying certain safari files are missing other cant due to some permission being denied even though I am running them through sudo su.
I then found a fix.
pip install pyobjc --user
This worked and I could access all the modules I required, but then if I try running python through sudo, I cant access those modules.
Can anyone suggest a fix for this.
NOTE: I don't mind a different method to install also. Also I have not tried brew due to some previous difficulties with it.
NOTE 2: I need to be able to access those modules using all users on the computer, the root user and me(the non-root user)
i had to (temporarily) move (using sudo) /Library/Python/2.7/site-packages/Extras.pth to another name before I could install the current pyobjc.
This is what works for me:
sudo mv /Library/Python/2.7/site-packages/Extras.pth /Library/Python/2.7/site-packages/Extras.pth_orig
pip install --upgrade pyobjc
sudo mv /Library/Python/2.7/site-packages/Extras.pth_orig /Library/Python/2.7/site-packages/Extras.pth
It appears that something in the .pth file interferes with the install, but does not impede running pyobjc.
but then if I try running python through sudo, I cant access those
modules.
Because sudo python basically means run python as some other user (root by default). That user may have a different set of environment variables, including $PATH.
Some of linux distributions use older Python version for root user,like centos.If the Python verison you're running with sudo isn't correct,you can't access those modules installed by pip.
So in my opinion,if you didn't get permission issues,you don't need to use sudo ,using sudo might bring unexpected mistakes(most environment variables issues),maybe chown or chmod can fix those issues.
So here are my plans:
Plan A: The best way is to try to use virtualenv.
Plan B: Install modules without sudo command,if got permission errors(not very common),try --user .
Install to the Python user install directory for your platform.
Typically ~/.local/, or %APPDATA%Python on Windows.
In most cases,you should modify your PYTHONPATH.See details from How do I access packages installed by pip --user.
Plan C: All related commands are executed with sudo.sudo pip install (all modules) and sudo python script.py.Not a good idea.
I want to run a python script on a Linux Box(I'm connecting to it through SSH on OSX terminal). In order for this script to run, the computer must have the SUDS module installed. I was wondering what would be the best way to install SUDS on computers that run my script and do not have SUDS installed in them. My script is in a folder the has a virtual env. The structure of my folder is:
MainFolder
-------script.py, env folder
|----------binFolder, includeFolder, libFolder
Should I code my script to install SUDS from the script itself?Or is there a better method to achieve this?
Also, I would like to know if there's a way to run my virtualenv through the SSH and use pip to install in the Linux Box?
Well it depends if you are deploying it only on this server and do not want to distribute the code than you would have to run the following command (assuming you have pip and python-tools)
sudo pip install SUDS
but if you get an error back saying that the command pip is not installed you will need to run the following command
sudo apt-get install python-pip python-dev build-essential
If you want to distribute it than I would do open source on github
with the instructions of how to use the program and run it I would add a dependencies list of all the external modules you used for your script.
Hope this helped.
I'm using the most recent versions of all software (Django, Python, virtualenv, MySQLdb) and I can't get this to work. When I run "import MySQLdb" in the python prompt from outside of the virtualenv, it works, inside it says "ImportError: No module named MySQLdb".
I'm trying to learn Python and Linux web development. I know that it's easiest to use SQLLite, but I want to learn how to develop larger-scale applications comparable to what I can do in .NET. I've read every blog post on Google and every post here on StackOverflow and they all suggest that I run "sudo pip install mysql-python" but it just says "Requirement already satisfied: mysql-python in /usr/lib/pymodules/python2.7"
Any help would be appreciated! I'm stuck over here and don't want to throw in the towel and just go back to doing this on Microsoft technologies because I can't even get a basic dev environment up and running.
If you have created the virtualenv with the --no-site-packages switch (the default), then system-wide installed additions such as MySQLdb are not included in the virtual environment packages.
You need to install MySQLdb with the pip command installed with the virtualenv. Either activate the virtualenv with the bin/activate script, or use bin/pip from within the virtualenv to install the MySQLdb library locally as well.
Alternatively, create a new virtualenv with system site-packages included by using the --system-site-package switch.
source $ENV_PATH/bin/activate
pip uninstall MySQL-python
pip install MySQL-python
this worked for me.
I went through same problem, but using pip from virtualenv didn't solve the problem as I got this error
error: could not delete '/Library/Python/2.7/site-packages/_mysql.so': Permission denied
Earlier I had installed the package by sudo pip install mysql-python
To solve, copy files /Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7.egg-info and /Library/Python/2.7/site-packages/_mysql* to ~/v/lib/python-2.7/site-packages and include /usr/local/mysql/lib in DYLD_LIBRARY_PATH env variable.
For the second step I am doing export DYLD_LIBRARY_PATH=/usr/local/mysql/lib in ~/.profile
Installed Django from source (python setup.py install and such), installed MySQLdb from source (python setup.py build, python setup.py install). Using Python 2.4 which came installed on the OS (CentOS 5.5). Getting the following error message after launching the server:
Error loading MySQLdb module: No module named MySQLdb
The pythonpath the debug info provides includes
'/usr/lib/python2.4/site-packages'
and yet, if I ls that directory, I can plainly see
MySQL_python-1.2.3-py2.4-linux-i686.egg
Using the python interactive shell, I can type import MySQLdb and it produces no errors. This leads me to believe it's a Django pathing issue, but I haven't the slightest clue where to start looking as I'm new to both Django and python.
EDIT: And to be a bit more specific, everything is currently running as root. I haven't setup any users yet on the machine, so none exist other than root.
EDITx2: And to be even more specific, web server is Cherokee, and deploying using uWSGI. All installed from source.
Have you considered installing MySQLdb from python packages?
I would also recommend doing this with pip instead of easy_install.
First you can replace easy_install with pip:
easy_install pip
pip install pip --upgrade
And then install Django via PIP:
pip install MySQL-python
pip install Django
Typically easy_install is installed already (part of setuptools), while pip is much better. It offers uninstallation options too, and uses flat install directories instead of the EGG files magic. This might resolve some incompatibilities as well.
Did you try building the dependencies? This solved it for me on Ubuntu:
sudo apt-get build-dep python-mysqldb
pip install MySQLdb-python
What worked for me (Linux Mint):
sudo apt-get install libmysqlclient-dev (this was the key for me)
pip install mysql-python
pip install django
You can find out where Python is looking for it's libraries by invoking "python manage.py shell" from the directory base of your Django project. Then do:
import sys
import pprint
pprint.pprint(sys.path)
And you'll see where the python is pulling libraries from. Also try to do a "import mysql" to see if that's kicking out an error.
Finally, the pathing for the WSGI service is (likely) configured with the uWSGI setup in Cherokee - sorry, I don't know the details of that critter to make suggestions on how to determine where/how it's loading the library path.
I was having this same problem, but it was only an issue inside a virtualenv.
What I did to finally fix it was
workon [project_name]
pip uninstall django
pip install mysql-python
pip install django
So making sure you install mysql-python before django seems to work.
This is on a Ubuntu system and using virtualenv.
Try this if you are using
linux:- sudo apt-get install python-mysqldb
windows:- pip install python-mysqldb or
easy_install python-mysqldb
Hope this should work
This did the trick for me:
sudo apt-get install python-dev
pip install mysql-python
Solved my problem :)
in my case, Python was able to access mySQL, but Django (1.6) gave the error: "Error loading MySQLdb module: No module named MySQLdb"
I am on a Macbook OSX (Maverick), by the way.
When I tried to run
pip install mysql-python
I got an error during compilation : "clang: error: unknown argument: ‘-mno-fused-madd’ [-Wunused-command-line-argument-hard-error-in-future]."
The problem, it turns out, is an updated behavior of cc compiler with the new Xcode 5.1. When there is a parameter it doesn't recognize, considers it as a fatal error and quits. The solution to override this behavior can be found here:
http://bruteforce.gr/bypassing-clang-error-unknown-argument.html
This issue was the result of an incomplete/incorrect installation of the MySQL for Python adapter.
Specifically, I had to edit the path to the mysql_config file to point to /usr/local/mysql/bin/mysql_config.
Discussed in greater detail in this article:
http://dakrauth.com/blog/entry/python-and-django-setup-mac-os-x-leopard/