eclipse + jython: importError: No module named pycurl - python

I know this Error is known and there are a few solutions, but none worked for me.
I work with eclipse neon + jython 2.7 on a Mac. NO virtualenv.
I want to import pycurl, which is correctly installed!
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
The PythonPath in Eclipse is set to site-packages and pycurl and so on. i already tried every combination!
I restarted eclipse every time after changing something at the paths.
I tried different installations:
sudo -H pip install pycurl
easy_install pycurl
pip -v install pycurl
pip -v install pycurl --upgrade
But if it is installed with one of these methods. it will always say that its already installed, when trying to install via another command.
So I deinstalled and installed multiple times. I even tried it with the download of the pycurl website
So any suggestions, how to make this work?

I don't have much to do with pyCurl, but I try a guess.
Is pyCurl implemented as a ".so"?
If yes: It won't work, because Jython can't deal with it, because it's C-Stuff. Jython can only use pure Python or Java modules.
In that case you have to look for an alternative in Java/Python or you need to find/create a wrapper and use JNI.
If no: Did you add pyCurl in your project source folder the right way?
Did you "import" in your code the right way?

Related

How to install modules with Python 2.4.3

I could not find anything on google about installing modules on this particular version 2.4.3 so I'm asking here.
I need to install python-ssl to use ssl package with python 2.4.3
I do not have any Scripts/pip.exe in my Python24 folder...
I've tried most commands yum / pip etc... nothing seems to work.
How to proceed please ?
You would probably need to make use of one of ancient methods of installation. Try download ssl file from PyPI, unpack it, go to catalog which was created when you unpacked it and do python setup.py install.

Cannot uninstall 'numpy'

I've been trying to install astropy and at the end of the installation I get this message:
Cannot uninstall 'numpy'. It is a distutils installed project and thus
we cannot accurately determine which files belong to it which would
lead to only a partial uninstall.
I have tried: pip uninstall numpy and then I get the same message.
I have Python 2.7.10 in a macOS High Sierra version 13.10.5
This doesn't directly answer your question, but that's because you're asking the wrong question.
Astropy requires Python 3.5 or 3.6. Trying to get it working with Apple's pre-installed Python 2.7 is a waste of time. You might be able to get an old version working this way, but not by using the installation instructions on astropy.org, and it won't be supported even if you do.
The easy solution is to just Install the latest Anaconda 5.x with Python 3.6, because it comes with Astropy built in.
The almost-as-easy solution is to install Python 3.6 from either a python.org binary installer, or Homebrew, and then use pip3 or, better, python3 -m pip to install everything, as explained on the Astropy install page.
Either way, before doing anything else, you want to get back to a clean slate. In particular, you do not want pip, or any other scripts, attached to Apple's Python 2.7; they will only cause confusion. Assuming you can't reinstall macOS from scratch, the best way to do this is:
Look in /Library/Python/2.7/site-packages and delete everything there except for README and Extras.pth.
Look in /usr/local/bin for symlinks to anything in that site-packages. (If you don't know much about using Unix, try this command: ls -l /usr/local/bin | grep 2.7.) You'll probably have pip and pip2.7 here, and probably nothing else. But whatever you have here, delete it.
Now, when you install Python 3.6, the only thing named pip anywhere will be that Python 3.6's pip. You still want to use pip3 or python3 -m pip, but if you screw up and type pip by accident, it won't break anything.
Also, you should strongly consider using a virtual environment. See the Python Packaging Authority's User Guide (or the Anaconda docs, if you went that way) for more on this.
One simple solution I found:
sudo -H pip install astropy --ignore-installed numpy
I also had this issue and couldn't get around it in a clean way, but this is what I did:
Inside the Lib folder search "numpy" for an egg_info file (eg. numpy-1.11.0.dev0_2329eae.egg-info).
In my case, this is what Pip was looking at to determine if a current version already exists. I deleted it, then ran normal
pip install numpy
and installed the newest version.
I don't recommend this because I don't understand what it's doing under the hood and it doesn't properly uninstall the old version which could be a recipe for trouble down the line, but if you're desperate like I was then maybe this is a solution for you.

How do I install a Python library? [duplicate]

I'm having a hard time setting up python packages. EasyInstall from SetupTools is supposed to help that, but they don't have an executable for Python 2.6.
For instance to install Mechanize, I'm just supposed to put the Mechanize folder in C:\Python24\Lib\site-packages according to INSTALL.txt, but runnning the tests does not work. Can someone help shed some light on this? Thanks!
The accepted answer is outdated. So first, pip is preferred over easy_install, (Why use pip over easy_install?). Then follow these steps to install pip on Windows, it's quite easy.
Install setuptools:
curl https://bootstrap.pypa.io/ez_setup.py | python
Install pip:
curl https://bootstrap.pypa.io/get-pip.py | python
Optionally, you can add the path to your environment so that you can use pip anywhere. It's somewhere like C:\Python33\Scripts.
Newer versions of Python for Windows come with the pip package manager. (source)
pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4
Use that to install packages:
cd C:\Python\Scripts\
pip.exe install <package-name>
So in your case it'd be:
pip.exe install mechanize
This is a good tutorial on how to get easy_install on windows. The short answer: add C:\Python26\Scripts (or whatever python you have installed) to your PATH.
You don't need the executable for setuptools.
You can download the source code, unpack it, traverse to the downloaded directory and run python setup.py install in the command prompt
Starting with Python 2.7, pip is included by default. Simply download your desired package via
python -m pip install [package-name]
As I wrote elsewhere
Packaging in Python is dire. The root cause is that the language ships without a package manager.
Fortunately, there is one package manager for Python, called Pip. Pip is inspired by Ruby's Gem, but lacks some features. Ironically, Pip itself is complicated to install. Installation on the popular 64-bit Windows demands building and installing two packages from source. This is a big ask for anyone new to programming.
So the right thing to do is to install pip. However if you can't be bothered, Christoph Gohlke provides binaries for popular Python packages for all Windows platforms http://www.lfd.uci.edu/~gohlke/pythonlibs/
In fact, building some Python packages requires a C compiler (eg. mingw32) and library headers for the dependencies. This can be a nightmare on Windows, so remember the name Christoph Gohlke.
I had problems in installing packages on Windows. Found the solution. It works in Windows7+. Mainly anything with Windows Powershell should be able to make it work. This can help you get started with it.
Firstly, you'll need to add python installation to your PATH variable. This should help.
You need to download the package in zip format that you are trying to install and unzip it. If it is some odd zip format use 7Zip and it should be extracted.
Navigate to the directory extracted with setup.py using Windows Powershell (Use link for it if you have problems)
Run the command python setup.py install
That worked for me when nothing else was making any sense. I use Python 2.7 but the documentation suggests that same would work for Python 3.x also.
Upgrade the pip via command prompt ( Python Directory )
D:\Python 3.7.2>python -m pip install --upgrade pip
Now you can install the required Module
D:\Python 3.7.2>python -m pip install <<yourModuleName>>
pip is the package installer for python, update it first, then download what you need
python -m pip install --upgrade pip
Then:
python -m pip install <package_name>
You can also just download and run ez_setup.py, though the SetupTools documentation no longer suggests this. Worked fine for me as recently as 2 weeks ago.
PS D:\simcut> C:\Python27\Scripts\pip.exe install networkx
Collecting networkx
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS reques
t has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may caus
e the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer ve
rsion of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissi
ngwarning.
SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SS
LContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL con
nections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.
readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading networkx-1.11-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 664kB/s
Collecting decorator>=3.4.0 (from networkx)
Downloading decorator-4.0.11-py2.py3-none-any.whl
Installing collected packages: decorator, networkx
Successfully installed decorator-4.0.11 networkx-1.11
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object i
s not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade
to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplat
formwarning.
InsecurePlatformWarning
Or just put the directory to your pip executable in your system path.
As mentioned by Blauhirn after 2.7 pip is preinstalled. If it is not working for you it might need to be added to path.
However if you run Windows 10 you no longer have to open a terminal to install a module. The same goes for opening Python as well.
You can type directly into the search menu pip install mechanize, select command and it will install:
If anything goes wrong however it may close before you can read the error but still it's a useful shortcut.

Python imports wrong version of library outside of virtualenv

Need help updating a python package.
I have an implementation that requires the following import
from twisted.internet.ssl import optionsForClientTLS
"optionsForClientTLS" was added to the twisted framework with version 14(?). I think the non-virtualenv import is getting a dated version-- If that import is within a virtualenv that has twisted installed via pip, everything is fine. Import fails outside the virtualenv.
In the virtualenv
twistd --version
Shows 15.2.1. On the bare system it shows 13.2.0.
pip install twisted
....
pip freeze
shows
Twisted==15.2.1
Uninstalling twisted using pip and reinstalling didn't help. You can install twisted from apt-get using
sudo apt-get install python-twisted
and it installs the older version, but after purging it and installing using only pip I still get the older version.
Possibly related.
I solved the issue in a terrible way. It was a few days ago, so the paths may not be exactly right.
The assumption that there were two python packages was correct (I think.) I suspect the order of the paths in PYTHONPATH meant that the wrong version was being imported first, while pip was installing in a version that was later on in the path.
My "solution" was to copy the twisted directory from the up to date version to the older version. This was either from usr/local/lib/python... to usr/lib/python... or from ... site-packages to ... dist-packages. I can check again if someone has the same issue and can't resolve it.

Python cannot find dateutil.relativedelta

I am trying to run a program using paster serve, but I keep getting the error:
ImportError: No module named dateutil.relativedelta
I am running Python version 2.6.7 and dateutil version 1.5, so it should be installed.
Has anyone got any ideas as to why this would happen?
I am importing using
from dateutil.relativedelta import *
I can even see the package when I search:
/usr/lib/python2.7/site-packages/dateutil/relativedelta.pyc
/usr/lib/python2.7/site-packages/dateutil/relativedelta.py
/usr/lib/python2.7/site-packages/dateutil/relativedelta.pyo
UPDATE
Immediately I look at this and see that dateutil is only installed for Python 2.7, and I bet what I was doing was this:
sudo yum install python-dateutil
To which sudo would have switch to the default Python version (i.e., Python 2.7 instead of 2.6.4).
Solving this would have been as simple as:
su
(switch to virtual environment)
yum install python-dateutil
Using su and then switching to the virtual environment will give root access and install to the virtual Python directory. Using sudo will install libraries to the default directory, not the virtual environments site-packages.
I also ran into this issue. The simple solution I ended up using was to add --upgrade to the end of the command. This forced it to install it even though Python thought it was installed. This resolved the issue.
So if you have this issue, try the following:
sudo pip install python-dateutil --upgrade
It can't possibly hurt anything, so there is no harm in just forcing it to be reinstalled.
I had a similar issue but for a simpler reason. My fresh virtualenv simply didn't have dateutil installed and I didn't know the Python package name. I tried pip install dateutil, which obviously didn't work since the package name was incorrect. Running pip install python-dateutil instead worked (without resorting to sudo).
This looks like a problem of package installation to me. A troubleshooting list that comes to my mind:
Verify you installed the package.
If installed, verify that the files have been stored in the right directory (a directory accessible from your python interpreter (= in the PYTHONPATH, useful article here).
Verify permission on those files.
Restart your shell if you tried the import there.
Reboot your computer (ouch... it's 10 years since I started using GNU/Linux, but I still suffer from the bad memories of Windows! ;)
(The previous comment about installing python-dateutil helped me, so perhaps my comment helps someone else).
For those on Mac OS (v10.6 (Snow Leopard); I am not sure about other versions), the dateutils package is located by default at:
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/dateutil
whereas pip install writes the package out to:
/Library/Python/2.6/site-packages
and does not update the /Library/Python/2.6/site-packages/easy-install.pth file. As a result, when you import dateutil, you will still point to the old location, you can verify this by "import dateutil; dateutil.__file__".
So what I did (probably better methods are available) was to rename the old directory (/System/Library/.../dateutil) to dateutil.obsolete and restarted Python, then ran the same set of commands again. This doesn't do anything to the path file or sys.path, but skips the old dateutils package so you can get to the new one.

Categories

Resources