Please bear with me as I am completely new to programming/python, etc.
I am attempting to install the pycurl module on my local win32 machine. I do not know anything about compiling, and I have attempted to install the module through an msi installer located here:
http://pycurl.sourceforge.net/download/
and I am using the pycurl-7.19.5.win32-py3.4.msi download, with Python 3.4.
I have downloaded it, and when I attempt to run a python query using the command prompt, I receive the error:
ImportError: No module named 'pycurl'
When I run the script without importing pycurl, it runs fine, so I know I have python installed successfully.
What am I doing wrong? I don't want to resort to compiling as that is going in completely foreign territories for me. I'd like to learn how to install modules into python for future purposes as well.
Try installing pycurl from this site, where all modules are as Windows binaries. Installing it and then trying to import pycurl works fine for me (you have to download appropiate .whl for your Python version & platform, then run):
..\Downloads>pip install pycurl-7.19.5.3-cp35-none-win32.whl
Installing collected packages: pycurl
Successfully installed pycurl-7.19.5.3
..\Downloads>python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)] on win32
>>> import pycurl
>>> pycurl
<module 'pycurl' from 'C:\\Program Files (x86)\\Python 3.5\\lib\\site-packages\\pycurl.cp35-win32.pyd'>
The problem you describe may happen when you have multiple versions of Python installed without using virtualenv.
Use pip instead:
pip install pycurl
Edit 2020-12-11:
Pycurl no longer builds binaries. The last binaries available are for Python 3.4 or 3.5.
If you're still using Python 3.4/3.5, and you don't want to/can't build from source, you can install the last available official binary builds from pip using:
pip3 install --only-binary :all: pycurl
WARNING: the latest binary build may be behind the latest source version and therefore have security bugs.
Related
I have quite a few versions of python installed (running macOS). I installed scrapy with pip install scrapy, and it succeeded. When I use it e.g.
scrapy startproject newProject
I see ModuleNotFoundError: No module named 'six', indicating that I need to install that module (six).
Note: I could easily fix the specific error by installing six for all versions of python installed, but solving that problem isn't what I'm trying to work out here.
Specifically what I'm after here is how to know what version of python a command line utility is using when it runs?
pip install will install package under pythonxxx/site-packages, the concrete location is up to which python version the pip used.
use pip -V to see the pip path and the related Python version. For you question, missing six module, pip install six should be enough, which will install six to the same Python version of scrapy.
After install scrapy, we could also enter scrapy shell, and use the below code to see where scrapy is
scrapy.__file__
To check the version of python from within a script or the REPL you can use the sys module.
For example:
>>> import sys
>>> sys.version
'3.8.5 (default, Jul 21 2020, 10:48:26) \n[Clang 11.0.3 (clang-1103.0.32.62)]'
I would like to use paramiko for SFTP file transfer in Python 3.5. I know that paramiko depends on PyCrypto and have read about PyCrypto installation problems in Python 3.5. Although I have seen a number of questions regarding this topic, I have not found a solution to successful SFTP file transfer in Python 3.5.
My first question: is it possible to use Python 3.5 for SFTP file transfer? If so, will paramiko work? If the above will work, why I am I receiving the following errors when attempting to install PyCrypto?
error: [WinError 2] The system canot find the file specified
**Failed building wheel for pycrypto**
My second question: if paramiko will not work with Python 3.5, are there any alternatives or must I revert back to a previous python version for SFTP file transfer?
The solution was to install Python 3.5.1 on my Linux server and then pip install paramiko from there. I'm still not sure why PyCrypto cannot be installed in Python 3.5 for Windows but this was the only solution I was able to find.
You can install PyCrypto binaries for Python 3.5 if you don't have a C++ compiler installed (that pip need to use to compile this library)
Install a PyCrypto binary from this site :
https://github.com/sfbahr/PyCrypto-Wheels
The best way to do it, is:
64bits Python
c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whl pycrypto
32bits Python
c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win32.whl pycrypto
Of course replace c:\Python35\Scripts\pip.exe by your python pip path
To know your python version, run python and look at the architecture displayed between brackets:
C:\Users\utilisateur>python
Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Hope this can help.
So I'm trying to get a program that uses PyQt4 to work in PyCharm on my Mac, but whenever it tries to run, it says
INFO: Could not import backend "PyQt4":
No module named PyQt4
Trying to import PyQt4 using PyCharm's Package Manager generates this error:
Executed Command:
pip install PyQt4
Error Occurred:
0:428: execution error: The directory '/Users/pkillam/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Proposed Solution:
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'.
This only happens to certain packages which pip doesn't like, particularly those which use configure.py instead of setup.py as explained here.
Attempting to run the command from the console generates this error:
$ pip install PyQt4
Collecting PyQt4
Could not find a version that satisfies the requirement PyQt4 (from versions: )
No matching distribution found for PyQt4
$
Now, installing the package using homebrew claims to be successful, but I still get the initial error that PyQt could not be imported after homebrew installs it.. somewhere.
I've been running around in circles with this for the past day, any ideas?
You can try to install PyQt4 by downloading it from the official Website. Remember to download PyQt version same as your python version. If you have python 2.7 32bit then download PyQt4 32bit even if your computer is 64 bit.
Similarly, if you have Python 3.x 64bit then you need to download PyQt4 64bit.
You can check your Python version from the default Python 'IDLE'. It should be similar to this.
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
You could try PyQtX. It's not perfectly up-to-date, but maybe a quick solutions in your case.
I removed numpy and scipy contents from the system's Python 2.6.4 in order to install different versions for them and now I broke YUM. The error I get is the following:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named rpm
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.6.4 (r264:75706, Jun 4 2010, 18:20:31)
[GCC 4.4.4 20100503 (Red Hat 4.4.4-2)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
Also when I import YUM from inside the python console I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 23, in <module>
import rpm ImportError:
No module named rpm
Python is working fine and I managed to install numpy however I want to install scipy using YUM and I can't. Also when I run:
rpm --version
I get: RPM version 4.8.1.
Is there a way to solve this issue? I would be grateful for any advice or pointers towards solving this issue.
It looks like you don't have rpm-python installed. If yum was previously working, then it is difficult to see how the rpm module is not installed. Take a look in /usr/lib/python2.6/site-packages/rpm - that directory should exist, and should contain a couple of python files (__init__.py and transaction.py) and a shared library for rpm.
If the /usr/lib/python2.6/site-packages/rpm directory or the files are missing then you could try to install it. First check whether it is in the RPM database using rpm -q rpm-python. If it not installed then you can get the rpm from somewhere like this mirror and install it (rpm -ivh http://mirror.as24220.net/pub/fedora/linux/releases/20/Fedora/i386/os/Packages/r/rpm-python-4.11.1-7.fc20.i686.rpm). You will need to find the correct version for your Fedora and machine architecture.
More likely it will be (apparently) installed, in which case you could try force a reinstallation. Just be certain that you have access to the correct rpm of the same identical version, download it to be sure. If you are confident, then install with rpm -ivh --force rpm_file.
Then run python and see if you can import rpm and import yum.
I'm trying to use pymongo in the IDLE shell on MAC OS X 10.9, but I can only do it in terminal.
when I call import pymongo in IDLE I get the following error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pymongo
ImportError: No module named 'pymongo'
but I use python in terminal I get this:
$ python
Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo
>>>
I can then use it with MongoDB.
Have I made some sort of install error? I'm doing this to learn mongoDB so I'm relatively new to this. Any help is much appreciated.
From the information you supplied in the comments, it appears you have installed a version of Python 3.3.4 on your system but you have installed the PyMongo distribution to an instance of Python 2.7, probably the Apple-supplied system Python 2.7 shipped with OS X 10.9. When you install a third-party package (or "distribution"), it is normally associated only with the Python instance that you used to install it. There are several common ways to install such packages. One way is to use the easy_install command, as is suggested on the PyMongo page. However, the easy_install command is also associated with a particular Python instance. On recent OS X releases, Apple supplies easy_install commands that are associated with and install into the system Pythons. So it's a common pitfall on OS X to install a newer version of Python alongside the system Python but then use the default easy_install command with the result that the package you want ends up installed in the wrong Python version. One solution is to install a separate version of easy_install for each Python version you install. The easy_install command is provided by the setuptools package. However, these days the recommended installer tool for Python is pip which provides more features than easy_install, including the ability to uninstall packages, and is actively supported in the community.
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python3.3 get-pip.py
python3.3 -m pip install pymongo
python3.3 -c "import pymongo; print(pymongo.version)"
-> 2.6.3
You also need to install a version of pip for each Python instance that you use. There are other ways to invoke pip but, by using the way shown above, you know which version of Python you are using and you are less likely to end up with the situation you have now. There are other tools you can use in addition, like virtualenv, but, particularly on OS X, pip should be sufficient to handle most beginning use cases.