-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relative import path #123
Comments
Are you working with virtualenv? Did you install smop using pip? What
version it reports?
…On Wed, May 30, 2018 at 12:43 AM, tarakobeam ***@***.***> wrote:
Dear the author of SMOP,
I'd love to use this amazing package, followed the steps of instructions,
and got the following error using Python 2.7:
Traceback (most recent call last):
File "main.py", line 15, in
from . import options
ValueError: Attempted relative import in non-package
Looks like there are some relative path references? in the main.py, and I
am wondering if you meant to delete these lines and just simply import from
the smop directory.
Kindest,
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#123>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEhsG_mVOzJYR1qbY15Ph796ARUc_Vnbks5t3cDygaJpZM4USRR7>
.
--
Calligraphy of geese / Against the sky / The moon seals it /
(Buson/Hass)
|
yes, but I also have python on my system in addition to anaconda-4.0.0 and anaconda3-4.0.0, and I am actually using Python2.7 on my system. I downloaded the entire zip from this GitHub page and manually installed them as instructed in the readme. After deleting those |
SMOP is supposed to work "as is", without any help from the user side. My immediate suspicion is that you are running the wrong version of SMOP. When you say SMOP --version it should respond with as version number of 0.40 at least. |
Oh, so the one here (https://github.com/victorlei/smop) is not the latest version?? I basically downloaded it with zip from the github page. |
Yes it is. But I am trying to figure out why you get an error message.
Step one -- I want to be sure that you and me are running the same program.
So, when you type
smop --version
at the command prompt, what output you get ?
…On Wed, May 30, 2018 at 10:19 PM, tarakobeam ***@***.***> wrote:
Oh, so the one here (https://github.com/victorlei/smop) is not the latest
version?? I basically downloaded it with zip from the github page.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#123 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEhsG-4Zc987nSpOoQvUp939XU_QgogQks5t3vCogaJpZM4USRR7>
.
--
Calligraphy of geese / Against the sky / The moon seals it /
(Buson/Hass)
|
nothing. I tried many alternatives, but I could not figure it out, so gave up on it with Ubuntu 16.04. Now, I am trying to install it on my Mac, OS High-Sierra, and running into some issues. I will comment on issue #124 |
Excuse me for cutting in, Traceback (most recent call last): I tried on Python 3.6.4 |Anaconda or python 2.7 on macOS 10.13 but got the same message. I installed this by "git clone https://github.com/victorlei/smop.git" smop --version made the message below (regardless of installing through Python3.6.4|Anaconda or python 2.7) Traceback (most recent call last): Thankyou. |
In python 2.7 I was getting the same relative import issues as originally posted near the top, I tried switching from a virtualenv of 2.7 to a conda env of 3.6 and it's saying
I am running directly from the git folder I cloned, I didn't attempt to install I created a fresh environment in conda with python 3 and pip installed smog
Created new env with python 2.7 tried easy_install more or less it appears to have installed and worked, however the conversion failed to work. Hope this helps someone |
Hi, for me i just solved it when fix import paths ( example "from . import options" -> "import options" ). And then i run without installation. |
The issue comes from the To fix this, move the
to
|
Guys please get an updated version of smop. The version on pypi was
several *years* old and I was not aware of that.
Now fixed.
…On Thu, Jun 21, 2018 at 5:03 PM, Gabriel Perren ***@***.***> wrote:
The issue comes from the main.py file living inside the module's
directory and being executed as a script (see here
<https://stackoverflow.com/questions/16981921/relative-imports-in-python-3>
)
To fix this, move the main.py file one dir above (ie: where setup-py file
is) and change its imports like so:
from . import options
to
from smop import options
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#123 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEhsG7dgk-PphcA4vY8Nzh6TgGHVXXEQks5t-6eygaJpZM4USRR7>
.
--
Calligraphy of geese / Against the sky / The moon seals it /
(Buson/Hass)
|
I has the issue cloning the latest version in the repo, so I don't think that's the problem. |
I know that this package is designed for python 2..but as a reminder if you are willing to use python 3 you need to fix some typos |
Please point me to the typos. All major formats accepted :)
…On Sun, Jun 24, 2018 at 11:55 PM, hbake001 ***@***.***> wrote:
I know that this package is designed for python 2..but as a reminder if
you are willing to use python 3 you need to fix some typos
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#123 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEhsG8dwbVMBnPwRdhWcJDZZeCq6SDxxks5t__yngaJpZM4USRR7>
.
--
Calligraphy of geese / Against the sky / The moon seals it /
(Buson/Hass)
|
There is nothing in the package that is specific to py2. In fact it does
work locally with py3. Version 0.41 beta is supposed to work with py3.
What are the typos?
…On Sun, Jun 24, 2018 at 11:55 PM, hbake001 ***@***.***> wrote:
I know that this package is designed for python 2..but as a reminder if
you are willing to use python 3 you need to fix some typos
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#123 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEhsG8dwbVMBnPwRdhWcJDZZeCq6SDxxks5t__yngaJpZM4USRR7>
.
--
Calligraphy of geese / Against the sky / The moon seals it /
(Buson/Hass)
|
I meant it's needed to change the importing statements from
|
Was anyone able to resolve the error?
|
See my reply to avvaruvenkatsu on #111. It might be relevant.
Regards
Rob Wilkinson
… On 5/09/2018, at 07:54, Sandeep Ganji ***@***.***> wrote:
Was anyone able to resolve the error?
File "main.py", line 15, in <module>
from . import options
ImportError: cannot import name 'options'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@sandeepganji Using the solution by @Gabriel-p worked for me. However, I then encounter @hbake001 's problem... and this has probably something to do with me using python 3. This is what I found on that issue thus far Which says that the package gitsome is not supported in 3.6 When I try to use pip install.. I get this error message Collecting gitsome |
Okay.. small update.. I just tried python 3.4 and python 2.7 but with both I am getting the issue: "ply.yacc.YaccError: Unable to build parser" So I have no idea where to go from there.. EDIT: btw.. I am on Windows.. since I just want to convert some Matlab scripts, I was unaware what PLY actually is. So it seems that it is based on some unix libraries? Maybe that could be the source of the problem EDIT2: Windows shouldnt matter.. since it is all written in Python of course, as is said in the README.md... Anyhow, after a simple pip instal, instead of doing python setup.py install --user, everything worked just fine. |
This suggestion by @EvgeniyGunko worked to get the code running for me. I did a find and replace in files on "from . " to "from smop " after moving the main as suggested. I then went into the following files and added a '.' in between smop and whatever file it was referencing: An example of this change is "from smop.version import version". I installed smop using pip within a conda environment within python 2.7. It throws errors when running. I ran smop using the following commad "smop solver.m" from within the smop/smop folder. That led me to try the git cloned repo and I had to make the changes above to get the relative import error to go away. However, I still do not see an output from running the code. I think it is suppose to produce a "a.py" file but it produces nothing. What is suppose to happen after running smop and where can i see the result #update#
Then run smop with: I could see an output file at this point |
Thank you so much everyone who actively noted down your problems. @Codeguyross 's solution works the best for me! I did the exact 3 commends he put above. So basically to summarize:
|
Dear the author of SMOP,
I'd love to use this amazing package, followed the steps of instructions, and got the following error using Python 2.7:
Traceback (most recent call last):
File "main.py", line 15, in
from . import options
ValueError: Attempted relative import in non-package
Looks like there are some relative path references? in the main.py, and I am wondering if you meant to delete these lines and just simply import from the smop directory.
Kindest,
The text was updated successfully, but these errors were encountered: