I am a noob with installing python programs. I know there are a lot of Questions like this here, I have tried to find a solution for my problem but I can't fix it.
First of all, I am trying to install a program called Qarq. The readme says:
Setup
In order to get qark running, it must be present on your python path. If not, it may lead to module not found errors. This can be done for your current shell by running the following:
export PYTHONPATH={qark root directory}:$PYTHONPATH
Well, I type the command. I check the variable with an echo and I can see the directory in the variable. However, I type "python setup.py install" and I get this error:
santoku#santoku-PC:~/qark$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
Then, I read in a question here that you must install setuptools, so I did it. I ran the next command:
sudo apt-get install python-setuptools
But the problem is still there, I try to run "python setup.py install" and I get the same error.
On the other hand, the readme says you only need to execute "$ python qarkMain.py". I do that and I get the same error with different module:
santoku#santoku-PC:~/qark/qark$ python qarkMain.py install
Traceback (most recent call last):
File "qarkMain.py", line 30, in <module>
from qark.modules.IssueType import IssueSeverity
ImportError: No module named qark.modules.IssueType
I am using Python 2.7.12 (default, Nov 12 2016, 01:02:22) [GCC 4.8.4] on linux2. (Ubuntu 14.04.5 LTS)
I have tried to install qark on Ubuntu 16.04.1 LTS and it worked perfectly. I didn't need to install setuptools. Both have the same python version.
I guess the problem is python can't find the modules, maybe I have to move the qark directory to another directory.
I think that's all, if you need more extra information just ask me.
I need your help, I am sure my problem is a foolishness and easy to fix. But I am a noob with python and I don't have any idea.
Thank you very much and thanks in advance.
Sorry for my English, I am not a native speaker.
EDIT: I found a solution, I tried to install again the OS and now python works properly, I don't know if I broke python or I did something bad. Anyway, Thanks.
i could get it work typing this:
1) PYTHONPATH=\home\santoku\qark\qark\:$PYTHONPATH
then just type:
2) python qarkMain.py
Related
I am having trouble installing a custom python module I have written.
Here are my steps so far:
Navigate to the module directory C:\Users\myname\repos\mymodulename where the setup.py file is in the anaconda prompt. Type: python setup.py install
The command prompt returns (plus some other things)
Extracting mymodulename-0.1-py3.7.egg to c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
mymodulename 0.1 is already the active version in easy-install.pth
Installing myclass-script.py script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installing myclass.exe script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installed c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages\mymodulename-0.1-py3.7.egg
Processing dependencies for mymodulename==0.1
...
Using c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
Finished processing dependencies for mymodulename==0.1
To me that looks like it has installed. Opening up the console and trying to import:
>>> import mymodulename.myclassas ce
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mymodulename'
>>>
It appears in hasn't. Checking the list of modules in anaconda with help('modules') confirms that it has not been imported.
I thought that perhaps i had installed it to the wrong environment:
(base) C:\Users\myname>conda env list
# conda environments:
#
base * C:\Users\myname\AppData\Local\Continuum\anaconda3
py2 C:\Users\myname\AppData\Local\Continuum\anaconda3\envs\py2
Only a python 2 environment which mymodule wouldn't be compatible with.
Does anyone have any suggestions about what I can try to resolve this? Happy to elaborate on any of the points
Thanks in advance.
EDIT: Some more information that may be relevant.
This package was initially installed in site-packages. I have reinstalled there and the package works. The reason I moved the package is because I am aware it is bad practice to store custom packages there.
When I was trying to import modules like "pymc3" or "theano", the rPython or PythoninR are not able to locate these modules even though I have already installed them. I am using Ubuntu 16.04, R 3.4.2, and python 3.5.2
It seems like these two packages fail to locate a certain folder, but it doesn't work after I append the path into sys.path, which contains all the packages I need, by using this command:
pyExec("sys.path.append('/home/lijiakai/.local/lib/python3.5/site-packages')")
Result also seems like good:
pyExec('import sys; print(sys.path)')
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages', '.', '/home/lijiakai/.local/lib/python3.5/site-packages']
I imported the packages:
pyExec('import pymc3')
Then received the following errors:
Traceback (most recent call last): File "<string>", line 1, in
<module> **ImportError** : No module named 'pymc3' Error in
pyExec("import pymc3") : An error has occured while executing
Python code. See traceback above.
Totally got me crazy ... really appreciate if anyone can help me out here.
Thanks
If you use anaconda, you might want to turn to turn to the package reticulate, where you can specify the python version to use.
# install.packages("reticulate")
library(reticulate)
use_python("/anaconda/bin/python")
However, from my experience this is slower.
Otherwise, if you use 'standard' Python, you can start by removing rPython:
remove.packages("rPython")
And then re-install it specifying the version:
install.packages("rPython", configure.vars= "RPYTHON_PYTHON_VERSION=3.5")
This should then use Python_3.5 on your machine, see here for more details.
You can test, if it was successful by using:
library(rPython)
python.exec(c("import sys", "\n", "print(sys.version)"))
Since updating from Homebrew Python 2.7.11 (from 2.7.10) I'm suddenly unable to test register my package on PyPi from the PyCharm IDE console.
Running (as an "External Tool")
python -B setup.py register -r pypitest
I now get
Traceback (most recent call last):
File "setup.py", line 22, in <module>
from setuptools import setup
File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.7/site-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 16, in <module>
from setuptools.depends import Require
File "/usr/local/lib/python2.7/site-packages/setuptools/depends.py", line 6, in <module>
from setuptools import compat
File "/usr/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Process finished with exit code 1
I'm not sure how to proceed. I only get this issue if I execute from within my IDE's console. If I do it directly at the system command line (Terminal on OS X) I have no problems.
OS X 10.11.3; Homebrew Python 2.7.11; PyCharm 5.0.3
tl;dr: Fix this issue by doing one of the following:
type hash -r python, OR
log out and log in.
EDIT: An answer to my related question makes it clear what's happening here. When you install a new version of python, you may need to run hash -r python to tell bash to reset the "cached" location to the python executable.
In my case, I was typing python, which was on my $PATH at /usr/local/bin/python. But bash was still using the old cache location /usr/bin/python. So, the old executable was called, but the new path was provided to python in sys.argv[0]. This means that the old executable was running, but the new sys.executable value caused all the wrong modules to get loaded (including the io module).
I'm having the same problem. I installed python 2.7.11 via an installer from Python.org. Strangely, the issue seems to be related to some subtle difference between how OSX launches python when I invoke it from the shell using the full path vs. using just the word python.
So, for me, this works (invoking python via the full path /usr/local/bin/python):
$ which python
/usr/local/bin/python
$ /usr/local/bin/python -c "import io"
$
... but this doesn't:
$ python -c "import io"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
So, as a workaround, you can try doing the same thing.
Elsewhere, I've posted a separate question about this puzzling behavior. Maybe somehow merely calling python invokes some strange mix of the 2.7.11 executable with the 2.7.10 dylibs??
According to https://github.com/klen/python-mode/issues/634:
I had the same issue, but successfully fixed. In my case I compiled
python and vim with homebrew, when PYTHON_PATH has been specified and
set to one of my dev environments, where I also had some libraries,
including io. Workaround was simple: open new terminal, make sure that
you do not have custom PYTHON_PATH, uninstall python, uninstall vim.
Reinstall both of them.
and
Problem solved.
Culprit is the update from python 2.7.10 to 2.7.11.
If you are using conda package control, simply run "conda install
python=2.7.10" will solve this problem.
This doesn't give the root cause though. Since this happens with _io, this looks like a bug in python 2.7.11 (unlikely, there would be a world-scale outcry and a prompt fix if it was) or some packaging bug or version mismatch specifically with the homebrew version (and maybe some related ones, too).
Try to import _io in the console and if it succeeds, check if it was loaded from the same path.
Reinstall python.
brew unlink python && brew reinstall python
Secure the path
export PYTHONPATH=$PYTHONPATH:/usr/local/bin/
BACKUP and Change the order of "paths" file.
sudo nano /etc/paths
it seems, the order of paths, it is decisive to run python properly. In my case, the result was:
#sudo nano /etc/paths
/usr/bin
/usr/local/bin
/bin
/usr/sbin
/sbin
On my mac, path is like this.
$ which python
/usr/local/bin/python
Now I can run both:
$ /usr/local/bin/python -c "import io"
$ python -c "import io"
I had the same issue, it is successfully fixed by just replacing the _io.so file.
sudo find / -name _io.so
copy the path of the _io.so file which DOES NOT belong to python-2.7.11. For example, copy the path of _io.so which is under python-2.7.5:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Replace the /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so file with the _io.so that you just found.
This happened to me as well in MacVim. I solved it by making sure :python print(sys.path) is using system Python (e.g. /Library/Python/2.7/...)
Since I installed MacVim via Homebrew, I just did that by:
Spawn a new shell that had which python -> /usr/bin/python. For my case I needed to remove the pyenv line from my .bash_profile. If you installed Python via Homebrew you may want to brew unlink python first
brew reinstall macvim
If your problem is caused by anaconda, it is unnecessary to remove //anaconda directory.
Just open your ~/.bash_profile, find the line
export PATH="//anaconda/bin:$PATH
and comment it out, then restart your terminal session.
Another quick workaround if you don't mind sticking with Python 2.7.10 is to specify the path of the Python interpreter executable that will be used for the virtualenv. On OSX that path is usually /usr/bin/python:
virtualenv venv --python=/usr/bin/python
Can't add comment (?) so this just to share my exp., downgrade to 2.7.10 works fr me.
I got this error after a failed NLTK download, I needed to uninstall anaconda:
sudo rm -rf ~/anaconda
update PATH variable
This happened when I already had tried to create a venv in a folder, and mistakenly was trying to initialize a second one! So I just removed venv directory and re-ran the command. Very likely this is not the answer to this solution, but searching my error brought me here, so it may help some others who are stuck.
I solved this issue by removing the symbolic link that was in /usr/local/bin and copying the actual python binary, that was pointed to by said link, there.
I had the same issue when I tried to use PyCharm. Solved by setting "python interpreter" in project configuration to point to the python virtual env I wanted to use, which was an Anaconda env. Somehow the interpreter path was missing the "anaconda" portion of ~/.../anaconda/.../_io.so. No need to uninstall anaconda.
I've been trying to install PyGMO on my Mac OS X 10.10. I'm using Anaconda Python 2.3, so it comes with python 3.4.
I followed the instructions on http://esa.github.io/pygmo/install.html and did try to build boost manually but didn't have much luck with building boost-python... The instructions I could find on the official website was very limited...
While using ccmake to run the build file in pagmo/build directory, it complained that it did not find boost-python3...
So I reverted to using brew to install boost. Thanks to the info I found on this page: http://ryanclouser.com/2015/07/16/Mac-OSX-Build-Boost-Python-with-Python3-Support/
Now I have both boost and boost-python installed, but still the ccmake process for PyGMO complains about not being able to find boost-python3.
Are there any environment variables I need to set? In the ccmake config screen do I need to set Boost_PYTHON3_LIBRARY_RELEASE or Boost_PYTHON3_LIBRARY_DEBUG?
LATEST EDIT: This SHA256 below mis-match is resolved. Turned out it was caused by source forge site being down when I ran the commands... Some better error messages would have helped.
However, when I tried to get boost and boost-python with brew, I got the following SHA256 hash code mismatch error.
Anyone has any idea how to fix this?
>$ sudo brew install boost-python --with-python3
==> Installing boost-python dependency: boost
==> Downloading https://homebrew.bintray.com/b...
####################################################################### 100.0%
==> Pouring boost-1.58.0.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/boost/1.58.0: 10718 files, 486M
==> Installing boost-python
==> Downloading https://downloads.sourceforge....
==> Downloading from http://downloads.sourceforge.n...
####################################################################### 100.0%
Error: SHA256 mismatch
Expected: fdfc204fc33ec79c99b9a74944c3e54bd78be4f7f15e260c0e2700a36dc7d3e5
Actual: 818a4b8bbcb50878a8b1b9f71b4274d242ab46bf860c74676e98dec1d0248821
Archive: /Library/Caches/Homebrew/boost-python-1.58.0.tar.bz2
To retry an incomplete download, remove the file above.
Tried to delete the cached boost package files as suggested a few times but it didn't work either.
Thanks guys.
Ok problem resolved. Here's the best practice to get boost on Mac OS X.
Use Homebrew! but the key is to use the --with-python3 switch! Credits to this page: http://ryanclouser.com/2015/07/16/Mac-OSX-Build-Boost-Python-with-Python3-Support/
>$ brew install boost-python --with-python3
Assuming you have CMake already, just follow the instructions on PyGMO's website.
pagmo/build>$ ccmake ../
This will then bring up the config screen, everything should look fine. If not, do rm -rf * in pagmo/build folder to clear everything and start again (this resolved the issue with boost-python3 for me mentioned above.
Then run make and sudo make install as mentioned on the website.
PyGMO should be ready for use in python after that!
I had the following error message. However, if I start python in the ~/anaconda/lib folder where I have my anaconda installed, import PyGMO worked, so it's probably some library path thing that needs to be fixed.
>>> import PyGMO as gmo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xxx/anaconda/lib/python3.4/site-packages/PyGMO/__init__.py", line 57, in <module>
from PyGMO import core, algorithm, migration, problem, topology, test, util
File "/Users/xxx/anaconda/lib/python3.4/site-packages/PyGMO/core/__init__.py", line 2, in <module>
from PyGMO.core._core import *
ImportError: dlopen(/Users/xxx/anaconda/lib/python3.4/site-packages/PyGMO/core/_core.so, 2):
Library not loaded: libpython3.4m.dylib
Referenced from: /Users/xxx/anaconda/lib/python3.4/site-packages/PyGMO/core/_core.so
Reason: image not found
**Latested EDIT: ** Did some searching around, a partial solution to the import error above, is to set DYLD_LIBRARY_PATH=~/anaconda/lib. With this, imports will work when you launch python in a console. However, IPython-notebook would not start for me... Also have seen that Max OS doesn't really have a dynamic search also...
I am facing these issues. Can you help me with the same ?
Why am I seeing this error ? Do I have to add anything in the requirements.txt file ?
>>> import git
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
import git
File "git\__init__.py", line 29, in <module>
_init_externals()
File "git\__init__.py", line 23, in _init_externals
raise ImportError("'gitdb' could not be found in your PYTHONPATH")
ImportError: 'gitdb' could not be found in your PYTHONPATH
>>> from git import Repo
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
from git import Repo
File "git\__init__.py", line 29, in <module>
_init_externals()
File "git\__init__.py", line 23, in _init_externals
raise ImportError("'gitdb' could not be found in your PYTHONPATH")
ImportError: 'gitdb' could not be found in your PYTHONPATH
I already had gitdb and smmap installed so I had to reinstall them.
You can reinstall them by running the following command in your terminal:
pip3 install --upgrade --force-reinstall gitdb; pip3 install --upgrade --force-reinstall smmap
I also got the message ImportError: 'gitdb' could not be found in your PYTHONPATH (when trying to use GitPython).BUT I had gitdb already installed!
Thanks to this hint I figured out that gitdb silently failed because it was missing smmap.
So I installed this and it worked.
You need to install gitdb package.
$ sudo easy_install gitdb
I had the same problem. However, gitdb and smmap were already installed by pip. As I used brew to install python and its dependencies on my mac, when I checked brew doctor command, it said that my /usr/local/sbin directory is not in my PATH. So I added it to my PATH (though it didn't have anything to do with the python) and everything worked out eventually.
MS Windows Versions of this problem can occur because of the order of Python versions in your system PATH, as it did for me. I did not realize that when I installed another program, it installed a newer version of Python for its own usage, and it appended my system PATH with the address to the newer version. I noticed it when I looked at the PATH variable and found two versions of Python being called. Windows uses the first it finds, and if the first doesn't match what your program expects, it gets confused and can't find the right path to the module. This is what I did to resolve it:
To check: an easy way to test if this is your problem is to see if the paths separated by semicolons are in the right order. That can be seen in the System Variables of Windows or by printing your PATH variable in your CMD shell like in this example:
C:> path
PATH=C:\Program Files (x86)\Python37-32\Scripts;C:\Program Files (x86)\Python37-32;C:\Program Files\Python38\Scripts;C:\WINDOWS
Temporary solution:
To see if it is going to fix your computer, change it in your CMD window. Your variable change will be discarded when the window is closed. One way to do this test is to copy the paths, move the Python references to the order they are needed, and write it back:
C:> set path = C:\WINDOWS;C:\Program Files (x86)\Python37-32;C:\Program Files\Python38\Scripts;C:\Program Files (x86)\Python37-32\Scripts\
Then run the Python program to see if this was your problem. Note that this is only an example; do not copy & paste it. Your path is customized for the programs on your computer.
Permanent solution: If the above test resolves your problem, you must change your System Variables to make the change permanent. For me that usually requires a reboot afterwards in order to make the variables appear in all new windows.