Hi, I’m having the same problem when I try to install packages to my computer. I tried the pip way as you described but it did not work for me. No matter what package I try to install, it always report to following errors:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘/private/var/folders/4m/3zz84kjj0rb8r7twkxksmplw0000gn/T/pip-req-tracker-dVJBGY/39e3ab1dfb11346e7d530d2e1ee1ef3dc8bbf9578e5f497994026cda’
and some times like this: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: ‘/Volumes/Slicer-4.10.0-macosx-amd64/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/python_dateutil-2.8.0.dist-info’
I was wondering if this is because I didn’t run slicer as an administrator. I’m using mac and when I right click on the icon, I didn’t see more and run as administrator. Does anyone know to run slicer on mac as an administrator? And does anyone know how to fix this error?
Please help.
Hi, Thank you for the advice! I checked and I think Slicer is at a writable location right now. And I also tried to open it as an administrator by command Applications andrealiang$ sudo open Slicer.app at the terminal. But I still get the following error: Requirement already satisfied: pandas in ./Slicer.app/Contents/lib/Python/lib/python2.7/site-packages (0.24.1)
Requirement already satisfied: python-dateutil>=2.5.0 in ./Slicer.app/Contents/lib/Python/lib/python2.7/site-packages (from pandas) (2.8.0)
Requirement already satisfied: numpy>=1.12.0 in ./Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.9-x86_64.egg (from pandas) (1.13.1)
Requirement already satisfied: pytz>=2011k in ./Slicer.app/Contents/lib/Python/lib/python2.7/site-packages (from pandas) (2018.9)
Requirement already satisfied: six>=1.5 in ./Slicer.app/Contents/lib/Python/lib/python2.7/site-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘/private/var/folders/4m/3zz84kjj0rb8r7twkxksmplw0000gn/T/pip-req-tracker-rEfQlE/20483040384e67f98bad799531b988be6a42bb897823a965fb554d64’
It looks like it has already installed the package pandas, but is having trouble with the second package. Does anyone know how to fix this bug?
Hi everyone, after days of trying, my problem is solved in two ways. And I’d like to share my solutions with you.
As for me, I’m using mac, and to successfully install the packages, mac users need to put the software in the directory Users/yourname/Applications rather than /Applications. Or if your software is in the directory /Applications, you can open it by option+open
you can use multithreading, which is to run Python script using a non-Slicer Python environment as described here.
I don’t get your point, no matter what I am not able to run multithreading, all packages run in a single processor even if they split threads. I have tried with multiprocessing, cython, numba, ipyparallel, joblib, handythreads. Everything has same behaviour, yes they can be installed but multithreading is just not working. Using an external python for this is not efficient since you have to pass big arrays (files). Can you elaborate more this point please?
Have you actually measured the time to pass large arrays through files? My experience is that if you don’t use compression then it works extremely fast. I guess that pickling of numpy arrays is quite well optimized, too. If you find that data transfer is the performance bottleneck then you can go lower level and use shared memory transfer.
For Slicer 4.10 I would probably suggest opening a terminal window to the location of PythonSlicer and doing PythonSlicer.exe -m pip install scipy. The error you are getting is because the “pip” package was updated and “main” was moved out. You could try some work around as was suggested earlier in this discussion such as
from pip._internal import main as pipmain
pipmain(['install','scipy'])
If using Slicer 4.11, Slicer is now using Python3. You could also use a helper function within Slicer’s python interactor. Try slicer.util.pip_install('scipy').
Reference: Use full power of Python in Slicer
Note: If you install scipy in Slicer 4.10, which is using python2, you will not be using the latest version of scipy (1.3.0). Scipy 1.3.0 is only available for Python3.
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘C:\Users\22374464\AppData\Local\Temp\pip-req-tracker-de0bnyq2\038c22fe9d64f3b52795137322e50c0d971005e9da8841928046b4a7’
Since you had issues using pipmain and I’m assuming you are using Slicer 4.10, then you should try PythonSlicer.exe -m pip install pynrrd to install this pure python package. Don’t use pipmain if you’re using Slicer 4.11 nightly.
If you’re using Slicer 4.11 nightly, you can easily use slicer.util.pip_install('pynrrd')as stayed above.
I see you are using windows, therefore you have installed Slicer into Programs files folder without writing permissions for slicer. You shall uninstall Slicer and reinstall in a writable folder like Documents, etc. This will solve your problems.
It seems that it is a recent Slicer Preview version, which installs itself to a writeable location by default, so write access should not be an issue.
pynnrd does not seem to be available on PyPI:
>>> pip_install('pynnrd')
Loading Slicer RC file [C:/Users/andra/.slicerrc.py]
Collecting pynnrd
Could not find a version that satisfies the requirement pynnrd (from versions: )
No matching distribution found for pynnrd
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.11.0-2019-07-15\bin\Python\slicer\util.py", line 2002, in pip_install
logProcessOutput(proc)
File "C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.11.0-2019-07-15\bin\Python\slicer\util.py", line 1955, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/Users/andra/AppData/Local/NA-MIC/Slicer 4.11.0-2019-07-15/bin/../bin\\PythonSlicer.EXE', '-m', 'pip', 'install', 'pynnrd']' returned non-zero exit status 1.
On your computer, there seem to be some cached pynrrd package, which is probably not compatible.
You should not need to import basic functionalities such as nrrd file reading from python.
You can read a nrrd file using vol=slicer.util.loadVolume('something.nrrd'), if you want to access it as a numpy array, call a=slicer.util.arrayFromVolume(vol). This approach has the advantage that you can directly manipulate the voxels that Slicer displays.
@lassoan The output error you posted happened because you tried to install pynnrd instead pynrrd. Just a simple typo.
I was able to successfully install this pynrrd package using slicer.util.pip_install('pynrrd'). I do think the previous errors have been due to some messed up cache of the download. Deleting that cache and then retrying should work.
Hi Andras,
gmsh-api is I need it within slicer. its succesfully installed but there is problem in using it within slicer. could you please help how to resolve the issue:
pip_install(“gmsh-api”)
Requirement already satisfied: gmsh-api in c:\users\22374464\appdata\local\na-mic\slicer 4.11.0-2019-07-06\lib\python\lib\site-packages (0.1.5)
Requirement already satisfied: pandas in c:\users\22374464\appdata\local\na-mic\slicer 4.11.0-2019-07-06\lib\python\lib\site-packages (from gmsh-api) (0.25.1)
Requirement already satisfied: numpy in c:\users\22374464\appdata\local\na-mic\slicer 4.11.0-2019-07-06\lib\python\lib\site-packages\numpy-1.16.2-py3.6-win-amd64.egg (from gmsh-api) (1.16.2)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\22374464\appdata\local\na-mic\slicer 4.11.0-2019-07-06\lib\python\lib\site-packages (from pandas->gmsh-api) (2.8.0)
Requirement already satisfied: pytz>=2017.2 in c:\users\22374464\appdata\local\na-mic\slicer 4.11.0-2019-07-06\lib\python\lib\site-packages (from pandas->gmsh-api) (2019.2)
Requirement already satisfied: six>=1.5 in c:\users\22374464\appdata\local\na-mic\slicer 4.11.0-2019-07-06\lib\python\lib\site-packages (from python-dateutil>=2.6.1->pandas->gmsh-api) (1.12.0)
but when I import the gmsh and try to run a script it gives me error. I am posting error below: The api works well on anaconda. I have used it before.
File “C:/Users/22374464/AppData/Local/NA-MIC/Slicer 4.11.0-2019-07-06/Mesher/MeshCreator/MeshCreator.py”, line 165, in run
import gmsh_api.gmsh as gmsh
File “C:\Users\22374464\AppData\Local\NA-MIC\Slicer 4.11.0-2019-07-06\lib\Python\Lib\site-packages\gmsh_api\gmsh.py”, line 39, in
lib = CDLL(libpath)
File “C:\Users\22374464\AppData\Local\NA-MIC\Slicer 4.11.0-2019-07-06\lib\Python\Lib\ctypes_init_.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None