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)"))
Related
When I try to run pythontex via my command line((base) Zachs-MacBook-Pro:mat_300 zachmaurus$ pythontex pythontex.tex) the following occurs:
Traceback (most recent call last):
File "/Library/TeX/texbin/pythontex", line 50, in <module>
import pythontex2 as pythontex
File "/usr/local/texlive/2019/texmf-dist/scripts/pythontex/pythontex2.py", line 61, in <module>
from pygments.styles import get_all_styles
ImportError: No module named pygments.styles
How do I go about solving this issue? I have downloaded pygments with pip install, but for whatever reason when I attempt to run the script the module pygments.style cannot be found.
Solved this issue by adding pythontex_install.py to my PATH using export PATH=$PATH:/usr/zachmaurus/Downloads/pythontex/pythontex_install.py in MacOS Terminal. To ensure that pythontex_install.py has been added to PATH environment run echo $PATH and it should appear as one of the variables. After having added pythontex_install.py to PATH, I now get the following result when I run pythontex pythontex.tex to compile my document:
This is PythonTeX 0.16
--------------------------------------------------
PythonTeX: pythontex - 0 error(s), 0 warning(s)
I solved this problem by explicitly call the interpreter I want, wenn I compile the document.
pdflatex -interaction=nonstopmode document.tex
python3 <path_to_pythontex.py>/pythontex.py document.tex
pdflatex -interaction=nonstopmode document.tex
or for any python interpreter you want:
pdflatex -interaction=nonstopmode document.tex
<path_to_python>/python3 <path_to_pythontex.py>/pythontex.py document.tex
pdflatex -interaction=nonstopmode document.tex
Of course Pygments module schuld be installed by this interpreter. This worked very good for me on macOS.
I got the same problem when I tried to use pythontex on my macbook (on macOS Catalina 10.15).
What I suggest below must be (if used) used with precaution :
I tried so many solutions and what actually worked for me was this :
I made sure that pygments was installed on my machine (I ran 'pip install pygments' on the terminal)
Then I changed the first line of the files pythontex, pythontex2 (because the problem seemed to come from there) and pythontex3
Theses files (if you are using macOS Catalina 10.15 like me) should be in
/usr/local/texlive/2021/texmf-dist/scripts/pythontex
(if you installed TexLive2021) -> you should be able to retrieve this path when you try to compile your tex file anyway...
The first line was replaced by #!/usr/bin/python3 (to ensure that python3 was used instead of python 2.7 which is used by default by macOS) inside the 3 files pythontex, pythontex2 and pythontex3 then :
I ALSO added this line (see the screenshot below) in pythontex3 :
sys.path.append('/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/')
to ensure that python found the module pygments
(because I installed python3.9 on my machine and the folder "pygments" and its subfolder "styles" was present in the folder "site-packages")
pythontex3 file
So now everything is working fine again and I can use pythontex =)
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.
I have seen many threads that have a high level of ambiguity and go off on tangents from the original question, often assuming much about the authors ability, so I am hoping that if I am direct and concise with my information, I will get an answer that is in line with the requirement. I know that the serious programmers will have seen this many times, in many formats, so please just bear with me as this is doing my head in. Please do not just post a link to some other answer as I rarely find that helps with my current issue.
I am not a hardcore programmer, I find the compiling, sourceball, tar, gz all nonsense to be honest and am looking for the easiest way to install sip for python on my machine. I have installed various versions of mingw32, mingw64 to the point that I don't know which one is best to use. I am assuming that the one here: C:\Program Files\mingw-w64 is the one, considering I am using 64 bit, but do the others I have installed impact on this?
I also installed versions of mysys:
C:\msys\1.0,
C:\msys64, but I still m unclear what and why etc, despite trying to read the docs that came with them.
I have windows 10, 64 bit professional edition.
I have python 2.7
I have installs of mingw, 32 bit and 64 bit in various locations, due mostly to not fully understanding what exactly it was or where it should go. I found zips of it and exes, so I got a bit confused.
I downloaded the sip package and unpacked it to here: C:\Python27\Lib\site-packages\sip-4.19.3 and it has the configure.py file in it. So far, so good.
I used a CMD window, changed directory to: C:\Python27\Lib\site-packages\sip-4.19.3 and then used the command: python configure.py to create the Makefile file which is what I believe is supposed to happen.
I then opened the mingw64 shell, changed directory to the above sip folder and typed: python configure.py again, just to be sure I would get a response and create the files again, probably should not have done so, but hey ho, at this point, I am quite frustrated with it and trying to do anything with what I have, which I know is poor practice. (see image 1.)
image 1: configure.py executed
From what I have read, I should use the make function that comes with Mingw64, but I tried the following, which also includes the configure.py code, but nothing seems to work when trying to use the Makefile file that was created via the configure.py process.
c:\Python27>cd ./Lib/site-packages/sip-4.19.3
c:\Python27\Lib\site-packages\sip-4.19.3> python configure.py
This is SIP 4.19.3 for Python 2.7.13 on win32.
The SIP code generator will be installed in C:\Python27.
The sip module will be installed in C:\Python27\Lib\site-packages.
The sip.pyi stub file will be installed in C:\Python27\Lib\site-packages.
The sip.h header file will be installed in C:\Python27\include.
The default directory to install .sip files in is C:\Python27\sip.
Creating siplib\sip.h...
Creating siplib\siplib.c...
Creating siplib\siplib.sbf...
Creating sipconfig.py...
Creating top level Makefile...
Creating sip code generator Makefile...
Creating sip module Makefile...
c:\Python27\Lib\site-packages\sip-4.19.3> Makefile
'Makefile' is not recognized as an internal or external command,
operable program or batch file.
c:\Python27\Lib\site-packages\sip-4.19.3> make Makefile
make: Nothing to be done for `Makefile'.
c:\Python27\Lib\site-packages\sip-4.19.3> Makefile Makefile
'Makefile' is not recognized as an internal or external command,
operable program or batch file.
c:\Python27\Lib\site-packages\sip-4.19.3>
So now I am at an impasse. I have the locations of my mingw versions and the msys in my path environment variable and I have done just about everything I have looked at on the web. I realise that its an order of things, but I really wish there were just executables for these modules and supporting tools as this compiling is a ball ache.I tried opening a python shell and importing sip.
>>> import os, sys
>>> import sip
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import sip
ImportError: No module named sip
>>> import sipconfig
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import sipconfig
ImportError: No module named sipconfig
>>> from sip import sip
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from sip import sip
ImportError: No module named sip
>>> from sipconfig impport sip
SyntaxError: invalid syntax
>>> from sip import *
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from sip import *
ImportError: No module named sip
So, if anyone has read through this and has a definitive answer as to what I am doing wrong, I would appreciate it.
make/nmake or make/nmake install cant be done from cmd and python path; instead using mingw or visual studio tools.
In windows search for prompt or Visual studio tools to open VS Command promt and from there cd--> sip file location (before this run configure.py present in sip folder)
Now run the commands nmake and then nmake install
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
I am trying to create an exe from python code. I can run the code just fine from the command line like this:
python myScript.py
I have installed py2exe from here: http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/
And, have a setup.py that looks like this:
from distutils.core import setup
import py2exe
setup(console=['myScript.py'])
And, I run the setup.py like this:
python setup.py py2exe
I get the following in the output:
The following modules appear to be missing
['Carbon', 'Carbon.Files', '__pypy__', '_scproxy', 'http_parser.http', 'http_parser.reader', 'jinja2._debugsupport', 'jinja2._markupsafe._speedups',
'jinja2.debugrenderer', 'markupsafe', 'pretty', 'socketpool', 'socketpool.util']
And, sure enough, if I try to run the exe, I get errors:
$ ./myScript.exe
Traceback (most recent call last):
File "restkit\__init__.pyc", line 9, in <module>
File "restkit\conn.pyc", line 14, in <module>
ImportError: No module named socketpool
Traceback (most recent call last):
File "myScript.py", line 12, in <module>
ImportError: cannot import name Resource
What do I need to do to get py2exe to find the dependencies?
Thanks
Carbon is the name of two different Mac-specific things.
First, in 2.x, on both Mac OS X and Mac Classic builds, has a Carbon package in the standard library, used for calling Carbon/Toolbox APIs (and, in OS X, CoreFoundation and friends).
Second, in both 2.x and 3.x, on Mac OS X, with PyObjC, the PyObjC wrapper around Carbon.Framework is named Carbon. (PyObjC isn't part of the stdlib, but it does come with Apple builds of Python, and most third-party builds besides python.org's official installers.)
Neither of these will exist on Windows.
py2exe tries to be smart and only import things relevant to your platform. However, it's pretty easy to fool. For example, something like this:
try:
import Carbon.Files
except:
Carbon = collections.namedtuple('Carbon', 'Files')
Carbon.Files = None
if Carbon.Files:
Carbon.Files.whatever(…)
… might make py2exe think Carbon.Files is required.
Now, obviously this isn't your whole problem, but it is a very big red flag that py2exe's module dependency code is not working for your project. You probably have similar problems with all kinds of other modules, so it's both missing some things you need and demanding some things you don't have, and this is probably what's causing your actual problems.
As the FAQ explains, you can debug this by running the module-finder code to see where it's going wrong, like this:
python -m py2exe.mf -d path/to/my_file.py
You could use this information to guide the module-finder code, or to rewrite your code so you don't confuse py2exe.
Or, more simply, just explicitly include and exclude modules in your setup.py as a workaround, without worrying about why they're getting incorrectly detected.
py2exe is python version dependent. Everything you're doing seems to be correct, I would guess you have the wrong version installed.