I'm have difficulty finding any docs describing Python's expected symlink behavior.
I've tried testing it myself but I'm getting weird results - sometimes it appears to work for a while then stops working.
Anyway, I have a situation where MoinMoin keeps it's data files and plugin modules in the same directory but I need to keep the data files outside my git repository (I'm using Openshift PaaS) so it persists. So I want to create this symlink:
~/data/plugins/theme/ -> ~/repo/plugins/theme/
Should I expect this to work?
Should work just fine - symlinks are handled on the OS level, meaning as long as python isn't trying to determine if something is a symlink or not, calling an open on it should just open the file it's pointing to.
Is there anything in particular that isn't working? What are you seeing when it stops working?
Related
Recently I uninstalled python and then reinstalled it to see what affects it would have on my code and ensure that I knew how to fix any path or directory issues. I mostly succeeded but am having trouble within my venvs. Testing out a basic django app I made any of my python manage.py ... code returns the error No Python at '"C:\Python311\python.exe'.
After doing some research it appears that the issue is that within .env\scripts there are two files called "python.exe" and "pythonw.exe" are causing the problem because they are trying to access a python.exe that no longer exists. (Note this is my understanding based off of pythons venv document and I could be incorrect)
My question is what is the best way to deal with this issue. I see two options but am not sure how to accomplish either.
Fully reset the .env folder so it points to the correct python.
Just change those two files so they point to the correct instance of python.
So far the only things I have tested are running code outside of venv's entirely and creating new ones to run the code from. Both work totally fine so it is definitely something from the historic venvs.
I have also looked at this question and I believe the two to be related but could be mistaken. Unfortunately it does not seem an answer was given there.
I was trying to add the Strings library into the Robot Framework Interpreter folder in PyCharm, where first it showed me error
Command errored out with exit status: 1
So, I googled out this issue first, and this link suggested me to delete 'strings.py' file from the libraries. I did so and now nothing is working.
Anything I do now, it shows error of "ModuleNotFoundError: No module named 'string'".
I could not even install string using
pip install strings
command.
Whatever I try to do with pip, now shows this error.
Can anyone please suggest me the solution for this?
I am using Python version 3.10.
Several notes:
The library in question is 9 years old, is not maintained, is known by the author to be buggy, was written as a joke, and does not contain anything useful. There is no good reason why you should be trying to install it for your project. If you think you need it for something, then you have some other misconception that needs to be cleared up.
The link you found did not tell you to delete strings.py from "the libraries". It said something about deleting string.py - notice, no s at the end - from a local project folder. The reason for this is because that name conflicts with the library name. The page author's own source file, named string.py, sought to import the standard library file string.py (as it clearly says import string in the screen shot), but it cannot - because it finds itself first. This is a common problem for new Python users.
DO NOT EVER MANUALLY EDIT THE CONTENTS OF YOUR INSTALLATION DIRECTORY ON THE ADVICE OF SOME RANDOM WEB PAGE.
Ideally, don't ever do it at all. That content is not intended to be touched. Installers exist for a reason. If for some incredibly specific reason you feel the need to do this, make sure you have backups of everything and that you are 100% sure you can restore everything to its initial state if anything goes wrong.
The person writing that web page was incorrect. The installation error had nothing to do with the string.py file.
The actual cause of the problem is that the package is broken and cannot be installed properly on anyone else's machine. Again, this is no big loss as there is no use for the package anyway.
The reason it is broken is that the setup script for the package tries to import the code that's being installed, in order to get version and author information. This seems to work locally, but fails for everyone else.
To reiterate: the person writing that article wrote nonsense. (I'm not surprised; the page formatting is awful and the grammar isn't particularly great either.) Looking further, it appears that the entire website is authored by the one person, who is clearly just trying to self-promote (with a Youtube channel as well) while lacking the necessary expertise. Browsing around the rest of the site a bit, I see articles that are pedantic and not very insightful, and occasionally inaccurate - but all very SEO optimized.
I recommend ignoring that website entirely.
To reiterate: the string module comes with your Python. You cannot reinstall it with pip - not with the strings package you found, nor any other package. Your options are:
Find the correct string.py contents (possibly from a backup, assuming you thought to make a backup before deleting something from an installation directory) and restore them. This is the official repository for the reference implementation of Python. You might be able to find it in there somewhere. I don't recommend trying. There is a lot to go through and it is possible to damage things further.
Reinstall Python completely.
The error that you are getting is because you deleted the string.py file. There is no string module to be imported from PyPi. This is why pip install string doesn't work. Restore the deleted file as it is not the cause of your problem.
If you try to install Strings library it will fail because you are using Python 3.10 and the Strings library that you want to import and install is quite old and not supported for this Python version. Therefore you get the ModuleNotFoundError: No module named 'strings' that you see in the link that you attached.
For the setup.py file from the library I see that it recommends using Python 3.3, so I will recommend you to use that version of Python if you want to use this specific library.
Please note that the link that you provided is probably in case that you have created your own string.py file.
I solved this question by deleting any __pycache__ folder in the project directory.
I am working on a Python project in VSCode with multiple files containing functions, being called from other files, like I have many other times.
However, I noticed that, sometimes, the following line appears at the top of some files:
from asyncore import read
I removed it, and now once I checked the file after altering others, it's back! It is making me go mad. It even is in the git push I did, although I am sure I removed it before sending it. Does anyone know what this is? Thank you.
You can disable it by adding this line to your user or workspace settings (File>Preferences>Settings, or Code>Preferences>Settings).
"python.analysis.autoImportCompletions": false
This Pylance extension setting is documented here. Turning of this setting is similar to this SO:answer except for Python instead of typescript.
Im going through the Microblog tutorial for Flask designed by Miguel.
I made it to part 4 without any issues. Everything ran in the end of part 4.
I started having issues in part 5. After a couple of tries and trying to troubleshoot with the comments in the page, I was not able to finish the exercise.
Thinking it was me, I deleted all of my project and replaced them with the zip downloadable in the page for the exercise. I still get the same error, so the problem is not the code itself.
I get the following error when running views.py:
Link to image on imgur (couldn't post it here due to not having enough reputation)
Here are the libraries I have installed:
Link to image on imgur (couldn't post it here due to not having enough reputation)
My setup:
I am using Pycharm to run the files. This machine runs Windows and I found that Pycharm is the most efficient way to run things without dealing with issues with the cmd line.
Python 3.4
virtualenv created by Pycharm
the code can be found on github: github.com/pdgonzalez872/microblog
Potential cause of the problem:
The problem may be with the path that I have set up (but why did it work until part 4?)
The code itself (maybe something was updated in flask/other libraries since the post?)
views.py isn't meant to be launched separately, there is run.py file to start the project.
Also, it uses relative imports (those with dots before module names), which don't work when you use them in a script passed to the interpreter and used as main. Sorry, I can't explain it well, but maybe you will be interested in those links:
https://docs.python.org/2/tutorial/modules.html#intra-package-references
How to do relative imports in Python?
I'm trying to use pyinstaller to build an exe from my python code. One of the modules I'm using is pubsub (pypubsub really. It used to be a part of wxpython). I'm getting errors when I try to run the exe. It complains "ImportError: No module named listenerimpl".
I've seen some articles about getting wx.lib.pubsub to work (it has known issues with pyinstaller). I've tried the solutions presented in those articles (slightly modified to account for it not being a part of wx anymore) but no luck.
I can get past the initial "ImportError: No module named listenerimpl" error by adding the path to the right listenerimpl (the kwargs one) to the list of files for Analysis in my spec file but then I hit further errors on importing "publisher". That error isn't fixed by adding its path in the spec file.
I think the solution shouldn't involve adding the path to listenerimpl.py in my spec file... but I'm not sure how to get this working happily.
extra info
using pubsub version: 3.1.1b1.201005.r243
using pyinstaller version: 2.0
platform: win7
pubsub problems solved (although exe still not running).
So if you look at comments here (especially comment #15 by sebastian.hilbert) it mostly solves the problems with some tweaking.
The necessary tweaks.
Change the names on the hook files to hook-pubsub.core.py and hook-pubsub.setuparg1.py.
Internal to those files you should get rid of references to wx.
Enable the hook files. You can do this one of two ways. The easy way is to drop these new hook files into 'pyinstaller-2.0\PyInstaller\hooks' which is where pyinstaller looks for hooks by default. The clean/nice way to do this is to put these hooks into their own folder and add that folder as hookspath in your spec file.
NB: It was not clear to me how to add a hookspath. In your specfile, in the call to Analyze, there is a hookspath arg. It wants a list not a string. So you want to do something like hookspath=['path1', 'path2', etc].
NB2: Additionally if you ask for "path.dirname(path.abspath(__file__))" you will get the directory for pyinstaller not the location where your spec file lives.
For those coming in late to this like myself, there's a new recommended procedure.
I recommend using oliver's PyPubSub. For Python 2.7, use his 3.4.2 release. Make sure you're only using this PubSub. This means if you have any other PubSub's in your env/lib/site-packages - not counting the one bundled with wxPython - you'll want to get rid of them. They WILL cause problems.
Despite what you may have read, do not use from pubsub import setupkwargs.
Don't add any new hooks to PyInstaller. They've already got it covered.
That's it. You're done.
Run PyInstaller. Check for any bugs in the build. Hopefully, PubSub won't be one of them.