I'm installing a Python (2.7.8) environment locally in my home folder on a server, in order to use newer versions of Python and some of its libraries (Numpy, Theano) together with OpenBLAS. For this, I first installed Python in the folder usr in my home directory (/home/my_home/usr/) as described here:
https://mail.python.org/pipermail/tutor/2002-March/012903.html
The installation seems to have gone smoothly. I checked this by starting the Python interpreter, which displays the right version on startup.
Following this, I installed OpenBLAS into /home/my_home/opt folder as described here:
Compiling numpy with OpenBLAS integration
... which also didn't give me any errors. However, now when I try installing Numpy (according to the instructions in the above link), I get the following error:
Traceback (most recent call last):
File "setup.py", line 22, in <module>
import subprocess
File "/home/ext_sxc/usr/lib/python2.7/subprocess.py", line 427, in <module>
import select
ImportError: No module named select
I suppose the straightforward thing to do is to find the package for select, compile and install it. I'm not sure if this is the right thing to do because the last time I installed Python 2.7.6 locally in a home directory, there were no such errors. As I understand, the select module should have been installed along with Python.
This also happens when I try installing IPython in a similar way in my home folder. The library which gives the ImportError is different.
I'm wondering if these are related to a more general mistake I may have made while installing Python. I'd appreciate any advice on this issue. Please let me know if any additional information would help. Thanks!
Related
I'm doing some scientific computation in python, and recently switched away from Anaconda since it doesn't yet support python 3.10 (which has some new features I'd like to use). I am now running on python version 3.10.9. I have a pipenv virtual environment set up for this, and in it I've got numpy version 1.23.5 installed. (Trying to upgrade to a newer version fails with a bunch of errors -- if upgrading numpy ends up being necessary I'll need to open a new question to ask about how to get that working.)
Everything initially seems to be working fine, until I try to run a parallelized numpy computation. At that point, I get the error DLL load failed while importing _multiarray_umath: The specified module could not be found. Here's the associated traceback:
Traceback (most recent call last):
File "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\lib\site-packages\numpy\core\__init__.py", line 23, in <module>
from . import multiarray
File "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
from . import overrides
File "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\lib\site-packages\numpy\core\overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
I can import numpy just fine, and I can use various functions from numpy without issue as well. I only get problems when I specifically want to do some parallelized computations. At that point my console gets flooded with this error (as far as I can tell, it's printing nearly exactly the same thing over and over, presumably once for every worker that it tried to launch).
The following text is also included in the error message:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\Scripts\python.exe"
* The NumPy version is: "1.24.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
While this looks pretty promising, I've read through the documentation on that page and nothing seems to be addressing the particular issue I'm running into here.
Additional details about my setup: The virtual environment was set up with pipenv, using the --site-packages flag (as I don't seem to be able to properly install PyQt5 in the virtual environment, so I'm just sourcing it from the system). I've got numpy installed in both my system's site-packages - that is version 1.24.1 (which checks out with the error messages) - and in the virtual environment's site packages (I didn't explicitly install it there, it was installed as a dependency; the virtual version is 1.23.5). Uninstalling numpy from the system site packages does not fix the issue.
I've also tried completely deleting the virtual environment and reinstalling it from the pipfile, but that also doesn't fix the issue. The version of numpy which is installed in the virtual environment does indeed have a DLL in its .lib folder, so it's not just missing. As far as I can tell there's nothing weird about my path; just in case I tried manually adding the .lib folders where the DLLs live to the path. I added both the virtual and system site packages to the path, and tried sourcing them in various different orders, to no avail.
I'm kinda at the end of my ability to troubleshoot this at this point, hence this request for help. In the meantime I'm resorting to doing all of my computations serially, but (as you might imagine) this is very slow and not very sustainable for the long term. If nobody can help me fix this, I'm going to have to just go back to Anaconda and give up on features from the newer python versions until they support them. (Or maybe I can try working without a virtual environment, but I've messed up systems pretty badly that way before and I'm kind of loathe to take that approach).
I'm a complete novice as far as python is concerned, but need to install it for PlatformIO. I installed python-3.8.5-amd64.exe on Windows 10 and installed PlatformIO in VSCode. But when I try to do a build I get:
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\io.py", line 54, in <module>
ImportError: cannot import name 'open_code' from 'io' (unknown location)
Since io.py is installed as part of the python installation, I assume the 'open_code' symbol should be installed. Running the Repair option from python-3.8.5-amd64.exe and rebooting claims everything's fine, but it still fails.
Can someone explain, in simple terms, what I need to do to fix this?
Note: there's an answer here which indicates it's due to there having been 2 versions of python installed and that something's pointing at the wrong verison, but it doesn't explain how to fix it in any way that I understand (as well as being for a Linux installation).
Thanks.
The solution was to delete the .platformio folder from my user folder. Obviously, PlatformIO was 'remembering' the previous python install and confusing things!
this happened to me when multiple versions of Python was installed , and the PATH environment variable had a python path whose version was different from what i was executing. Adjusted the path variable to demote the unused python version and promote the currently used version and it solved the problem.thanks!
From IDLE, I tried to run a script with a newly installed scrapy 1.0.3.
I'm using a script from a friend whom it worked for (but on Windows, I'm on a Mac).
From the import of scrapy on the first line, I get this error when running the program:
ImportError: No module named twisted.persisted.styles
The whole script, if it's helpful, points to this:
Traceback (most recent call last):
File "/Users/eliasfong/tutorial/tutorial/spiders/medspider.py", line 1, in <module>
import scrapy
File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 27, in <module>
from . import _monkeypatches
File "/Library/Python/2.7/site-packages/scrapy/_monkeypatches.py", line 20, in <module>
import twisted.persisted.styles # NOQA
ImportError: No module named twisted.persisted.styles
Any suggestions on how to tackle this problem?
Just try to force the update of twisted :
pip install twisted --upgrade
That works for me with python3.4 and Scrapy==1.1.0rc1
Either twisted is installed on your mac (I highly doubt it since it's not a standard library) and for whatever reason the IDE (i'm assuming that's what you mean since you typed "idle") or the terminal you are in doesn't have your updated environment variables, meaning it doesn't understand where your default python libraries are (again I highly doubt it), or you simple do not have twisted installed on your mac. If it's not installed you have a couple of options:
The easiest way to install a python package is through pip.
If that not an option you can try homebrew which is another package manager for macs. It offers an easy way to install packages correctly.
If that still is not an option for you or you simply don't want to attempt that you can download twisted directly from here (the .bz2 since you're on a mac), click on it and it should unzip it for you. Then just run setup.py and it should install it in the correct location on your mac.
If that still doesn't work and you have decent knowledge of unix. Use the "locate" command on the terminal and find out where your dist-packages directory is and put the source for twisted in there directly and then attempt to import twisted in your IDE or in the python interpreter to verify that it is installed.
note: If you're still having problems after it is installed trying restarting your IDE or messing with some setting to make sure your IDE has the right environment and python path. Hope that helps!
It could be related to having installed Python without bzip2. I had the same error and this helped me, see the accepted answer here:
Installing Twisted through pip broken on one server
Had this exact thing on FreeBSD. Solution (as root/sudo):
chmod -R go+rX /usr/local/lib/python2.7/site-packages
Some directory permissions weren't set up right on install.
I downloaded Python module libgmail from sourceforge and extracted all the files in the archive. The archive had setup.py, so I went to that directory in command prompt and did
setup.py install
I am getting the following error message
I:\libgmail-0.1.11>setup.py install
Traceback (most recent call last):
File "I:\libgmail-0.1.11\setup.py", line 7, in ?
import libgmail
File "I:\libgmail-0.1.11\libgmail.py", line 36, in ?
import mechanize as ClientCookie
ImportError: No module named mechanize
This may be trivial, but I am new to python. So plz guide what to do.
please note, I am using python 2.4 and using Windows-XP.
Thank you
MicroKernel
I think this lib depends on this one:
http://wwwsearch.sourceforge.net/mechanize/
Try installing it first.
You need to download and install the module called mechanize. Depending on your operating system (ie. Linux), your package manager probably has something for this, otherwise you will need to google it, and follow it's installation instructions.
easy_install mechanize
If this doesn't work, you need to fix your PATH environment variable to include path to your python installation directory\scripts. easy_install will save you a lot of time in future.
P.S.: Python 2.4 is 6 years old, you should really consider at least 2.6.
I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by default in the considered version of Python. However, I have some troubles. When I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "", line 1, in File "/home/verrtex/opt/lib/python2.6/sqlite3/init.py", line 24, in
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: No module named _sqlite3
As I have already told to, the possible reason of this problem is that the module in tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. This explanations is supported by the fact that I do not have _sqlite3.so file in my "/home/verrtex/opt/lib/python2.6/lib-dynload" directory. So, this is the problem I have to solve (I have to get this file to this directory).
I found out that to solve this problem I have to "install sqlite3 and recompile Python". I also found out that the problem can be solved by "building from source and moving the library to /usr/lib/python2.5/lib-dynload/".
However, it is not clear to me what exactly should I do. Should I install python module called "sqlite3" or I should install sqlite-database? By the way, I have already sqlite-database installed globally by the administrator. Can I use it or I still have to install my own database? By the way, I do not have root permissions. Can it be a problem? Or I need to install a python module? Is absence of root permissions a problem, in this case?
I also has been told to, to take source files from SQLite Download Page, extract archive, move to expanded directory and execute:
./configure
make
make install
Then I have to copy newly compiled files to my Python directory. Should I copy all newly compiled files? And to which exactly directory should I copy (my Python directory have some subdirectories)?
Would very appreciate any help, because I stack with this problem for a wile.
P.S. My OS is CentOS release 5.3 (Final).
Your sys.path is likely not pointing to your locally installed copy, or you're not running the Python 2.6.2 you think you are.
If none of that is the case, you need the SQLite development headers (sqlite-dev or whatever), and then recompile Python. You need to pay attention at the end of the compile, because it complains about what it didn't build due to missing dependencies.
EDIT: Reread question.
EDIT 2: Also, please don't do this:
from module import *
Do this:
from module import what_i_need
import module2
Although you might have found your solution, I just wrote mine down for someone who are stuck in the same problem.
My OS is CentOS 6.3(Final) with python2.6.
I install python2.7.3 in my system, but the problem's still there. (_sqlite3.so should be in /path/to/python2.7.3/lib/python2.7/lib-dynload after python2.7.3 has been installed. Because before python2.7 was installed, sqlite-autoconf-3071502.tar.gz was installed.)
I then copy the /path/to/python2.6/lib/python2.6/lib-dynload/_sqlite3.so to the python2.7's path. And type in the python-shell:
>>> import sqlite3
or
>>> import _sqlite3
No error reports.
Unfortunately, the damn error appeared as before when I run my python script.
I install sqlite-devel(sudo yum install sqlite-devel or download here), and then reinstall python2.7.3 again. Run my python script again. Thank goodness! The damn error finally solved.